首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

,Repeater输出,第1条记录输出,某个参数固定

2012-09-04 
高手请进,Repeater输出,第1条记录输出,某个参数固定这是我现在的代码前台页面HTML codeasp:Repeater ID

高手请进,Repeater输出,第1条记录输出,某个参数固定
这是我现在的代码
前台页面

HTML code
<asp:Repeater ID="Top_GG01" runat="server"><ItemTemplate>    <div class="dis" name="f"><a href="ProductDef.aspx?id=344" target="_blank"><img src="../upload_pic/Pro/<%# Eval("picture_b")%>" onload= "resize(this,this.height)"/></a></div></ItemTemplate></asp:Repeater>

CS文件
C# code
    public void ProTop_1()    {        ODBdata da = new ODBdata();        string sql = "select top 5 * from product where isEncrypt=false order by ID desc";        DataSet ds = da.ExceDS(sql);        PagedDataSource pds = new PagedDataSource();        Top_GG01.DataSource = ds.Tables[0].DefaultView;        Top_GG01.DataBind();    }

--------------------------------------------
现在想实现的就是 DIV里的 class="dis" ,第一条记录的时候是 class="dis",然后后面的记录都是 class="undis"

要实现成这样(如下):
HTML code
<div class="dis" name="f"><a href="ProductDef.aspx?id=344" target="_blank"><img src="../upload_pic/Pro/<%# Eval("picture_b")%>" onload= "resize(this,this.height)"/></a></div><div class="undis" name="f"><a href="ProductDef.aspx?id=344" target="_blank"><img src="../upload_pic/Pro/<%# Eval("picture_b")%>" onload= "resize(this,this.height)"/></a></div><div class="undis" name="f"><a href="ProductDef.aspx?id=344" target="_blank"><img src="../upload_pic/Pro/<%# Eval("picture_b")%>" onload= "resize(this,this.height)"/></a></div>


[解决办法]
<asp:Repeater ID="Top_GG01" runat="server">
<ItemTemplate>

<div class="<%i==0?"dis":"undis" %>" name="f">
<a href="ProductDef.aspx?id=344" target="_blank">
<img src="../upload_pic/Pro/<%# Eval("picture_b")%>" onload="resize(this,this.height)" /></a></div>
<%i=i+1; %>
</ItemTemplate>
</asp:Repeater>


后台
protected int i = 0;
protected void Page_Load(object sender, EventArgs e)
{
[解决办法]
HTML code
<a class='<%# Container.ItemIndex==0?"dis":"undis"  %>'>ssss</a> 

热点排行