Repeater

在Repeater1中点击 点击查看详情按钮 在Reperter2中显示信息

protected void _details(object sender,EventArgs e)
        {
            this.Panel2.Visible=true;
            HtmlAnchor a = (HtmlAnchor)sender;//取出reperter1中的a标签中的内容
           int productid=Convert.ToInt32(a.Title.ToString());//取出a标签中title上绑定的值

             //绑定
           string sql = string.Format("select Description from Products.dbo.Products where productid='{0}'", productid);
            DataSet ds = CM.DataAccess.dataDrive.Welanerp.connProcedureExecSql(sql);
            this.Repeater2.DataSource = ds;
            this.Repeater2.DataBind();
        }

<asp:Panel ID="Panel1" runat="server" Visible="true">
        <asp:Repeater ID="Repeater1" runat="server">
            <HeaderTemplate>
                <table width="100%" cellspacing="1" cellpadding="0" class="underline">
                    <tr style="height: 40px" align="center">
                    <th>书名</th>
                    <th>作者</th>
                    <th>出版社</th>
                    <th>ISBN</th>
                    <th>内容简介</th>
                    <th>图书编号</th>
                    </tr>
            </HeaderTemplate>
            <ItemTemplate>
         
  <tr align="center" style=" background-color:Green ">
            <td><%#Eval("ProductName")%></td>
            <td><%#Eval("AuthorNames")%></td>
            <td><%#Eval("ManufacturerName")%></td>
            <td><%#Eval("BarCode")%></td>
            <td><%#Eval("Description")%></td>

           //显示详情按钮  注:鼠标点击时间必须为onserverclick(按钮点击时间在后台编写 即上)
            <td><a id="Seache" href="javascript:" runat="server" title='<%#Eval("ProductID") %>' onserverclick="_details">详细信息</a></td>
            </tr>
            </ItemTemplate>

             //隔行颜色效果

            <AlternatingItemTemplate>
            <tr align="center" style=" background-color:red">
            <td><%#Eval("ProductName")%></td>
            <td><%#Eval("AuthorNames")%></td>
            <td><%#Eval("ManufacturerName")%></td>
            <td><%#Eval("BarCode")%></td>
            <td><%#Eval("Description")%></td>
            <td><a id="Seache" href="javascript:" runat="server" title='<%#Eval("ProductID") %>' onserverclick="_details">详细信息</a></td>

           </AlternatingItemTemplate>


            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
    </asp:Panel>


    <asp:Panel ID="Panel2" runat="server" Visible="false">
        <asp:Repeater ID="Repeater2" runat="server">
        <HeaderTemplate>
        <table width="100%" cellspacing="1" cellpadding="0">
         <tr align="center">
         <th>描述</th>
         </tr>
        </HeaderTemplate>
        <ItemTemplate>
        <tr align="center">
        <td> <%#Eval("Description")%></td>
        </tr>
        </ItemTemplate>
        <FooterTemplate>
        </table>
        </FooterTemplate>
        </asp:Repeater>
    </asp:Panel>

原文地址:https://www.cnblogs.com/happygx/p/1957950.html