日期:2014-05-16  浏览次数:20529 次

点击repeater控件中某行按钮时候 该行变色
repeater 结构:
 <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
             <HeaderTemplate>
                    <table class="table2" >
                        <tr>
                          
                            <th style="width:30px;">ID</th>
                            
                            <th>产品</th>
                            <th style="width:30px;">库存</th>
                           
                            
                            
                        </tr>
              </HeaderTemplate>

。。。。。。。。。。。。。。。。。。。。    

<td style="text-align:left;padding-left:3px;"> <asp:LinkButton ID="LinkButton3" runat="server" CommandArgument='<%#Eval("id") %>' CommandName="show" OnCommand="caozuo" ><%#Eval("proname") %></asp:LinkButton></td>




-----------------------------
 protected void caozuo(object sender, CommandEventArgs e)
    {
      这里应该怎么写?让 该reptaer 控件 该行 变背景色

}
------解决方案--------------------
这个可以在前台设置的,也可以后台设置

前台:
//repeater隔行换色代码
<tr class='<%#(Container.ItemIndex%2==0)?"TrGray":"TrWhite"%>'>

后台:
HTML code
<asp:Repeater ID="Repeater1" runat="server">
            <ItemTemplate>
                <div runat="server">里面的控件放在这里</div>
                <br />
            </ItemTemplate>
        </asp:Repeater>

C# code
(Repeater1.Items[3].Controls[1] as HtmlGenericControl).Sty