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

高手请进,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>