日期:2014-05-17  浏览次数:20480 次

.net repeater 控件绑定数据控制的问题,大虾麻烦帮看一下
<asp:Repeater ID="indexHmtl3" runat="server">
  <ItemTemplate>
  <dd><a target="_blank" href="/design_v<%Eval("arID").ToString())%>.html"><%#pubfunction.SubStr(Eval("arshortTitle").ToString(),20)%></a></dd>
  </ItemTemplate>
  </asp:Repeater>
===========================================
在 <ItemTemplate>里面显示的时候我要控制显示到第几条的时候,是什么样的:也就是显示结果要成这样
比如显示十条:(下面这个就是我想要的显示结果,就是当显示第二条的时候显示2,第5条的时候显示5,当第十点的时候前面显示一个图片
<dd><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
<dd><span>2</span><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
<dd><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
<dd><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
<dd><span>5</span><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
<dd><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
<dd><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
<dd><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
<dd><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
<dd><img src=""><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>

但是我现在云南结果是:
<dd><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
<dd><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
<dd><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
<dd><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
<dd><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
<dd><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
<dd><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
<dd><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
<dd><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
<dd><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
<dd><a target="_blank" href="/design_v2323.html>dklasdkflsafda</a></dd>
我不想要这样的
如何控制呀?

------解决方案--------------------
<ItemTemplate>
<dd><%#showstyle(Container.ItemIndex或Eval("数据库ID"))%><a target="_blank" href="/design_v<%Eval("arID").ToString())%>.html"><%#pubfunction.SubStr(Eval("arshortTitle").ToString(),20)%></a></dd>
</ItemTemplate>

.aspx.cs中
C# code
protected string showstyle(int id)
{
     if(id == 2)
     {
         //显示内容
     }
     …………
}

------解决方案--------------------
这样 应该可以

<dd><%# (Container.ItemIndex+1)%10==0?"<img src=\"/upload/shopcart.jpg">":Container.Ite