星空网 > 软件开发 > ASP.net

repeater三级嵌套绑定

<asp:Repeater ID="rpt1" runat="server" onitemdatabound="rpt1_ItemDataBound">         <HeaderTemplate> <table width=400 cellpadding=0 cellspacing=0></HeaderTemplate>            <ItemTemplate><tr>         <td><font color=black ><b><%# DataBinder.Eval(Container.DataItem,"CategoryName")%></b></font></td></tr>                  <tr><td align=right>                         <asp:Repeater ID="rpt2" runat="server">                             <HeaderTemplate>                                <table width=360 align=center cellpadding=0 cellspacing=0>                             </HeaderTemplate>                                  <ItemTemplate>                                       <tr>                                         <td align=left width=200 ><font color=black>+</font><%# DataBinder.Eval(Container.DataItem,"CategoryName")%></td>                                         <td width=80 align=center>                                             <a href=ProductSort.aspx?type=1&id=<%# DataBinder.Eval(Container.DataItem,"ID")%>>修改</a></td>                                                                                   <td width=80 align=center>                                           <a href=ProductSort.aspx?type=2&id=<%# DataBinder.Eval(Container.DataItem,"ID")%>>删除</a>                                         </td>                                       </tr>                                       <tr>                                          <td align=right colspan=3>                                               <asp:Repeater ID="rpt3" runat="server">                                                  <HeaderTemplate>                                                     <table width=320 align=center cellpadding=0 cellspacing=0>                                                  </HeaderTemplate>                                                     <ItemTemplate>                                                        <tr>                                                           <td align=left width=160 ><font color=black>-</font><%# DataBinder.Eval(Container.DataItem,"CategoryName")%></td>                                                           <td width=80 align=center>                                                               <a href=ProductSort.aspx?type=1&id=<%# DataBinder.Eval(Container.DataItem,"ID")%>>修改</a>                                                           </td>                                                            <td width=80 align=center>                                                                <a href=ProductSort.aspx?type=2&id=<%# DataBinder.Eval(Container.DataItem,"ID")%>>删除</a>                                                           </td>                                                        </tr>                                                     </ItemTemplate>                                                  <FooterTemplate>                                                     </table>                                                  </FooterTemplate>                                               </asp:Repeater>                                                                                   </td>                                       </tr>                                       <tr>                                                                               </tr>                                  </ItemTemplate>                             <FooterTemplate>                                </table>                             </FooterTemplate>                         </asp:Repeater>                    </td>                 </tr>                 <td height=15px; > </td>            </ItemTemplate>            <FooterTemplate>             </table>            </FooterTemplate>         </asp:Repeater>

后台。aspx.cs

    protected void rpt1_ItemDataBound(object sender, RepeaterItemEventArgs e)     {         if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)         {             Repeater rpt2 = (Repeater)e.Item.FindControl("rpt2");             //找到分类Repeater关联的数据项             DataRowView rowv = (DataRowView)e.Item.DataItem;             rpt2.ItemDataBound += new RepeaterItemEventHandler(rpt2_ItemDataBound); //最最重要的一句             //提取分类ID             cid = Convert.ToInt32(rowv["ID"]);             //根据分类ID查询该分类下的产品,并绑定产品Repeater             rpt2.DataSource = Pcategory.getP(cid);//数据绑定             rpt2.DataBind();         }     }     protected void rpt2_ItemDataBound(object sender, RepeaterItemEventArgs e)     {         if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)         {             Repeater rpt3 = (Repeater)e.Item.FindControl("rpt3");             //找到分类Repeater关联的数据项             DataRowView rowvv = (DataRowView)e.Item.DataItem;             //提取分类ID             cid2 = Convert.ToInt32(rowvv["ID"]);             //根据分类ID查询该分类下的产品,并绑定产品Repeater             rpt3.DataSource = getrpt3(cid, cid2);//数据绑定             rpt3.DataBind();         }     }

转载自:http://www.aspnetjia.com




原标题:repeater三级嵌套绑定

关键词:Repeater

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

跨境能量站:https://www.goluckyvip.com/tag/36842.html
跨境牛哥:https://www.goluckyvip.com/tag/36843.html
跨境拍摄Irving:https://www.goluckyvip.com/tag/36844.html
跨境拍摄Sum:https://www.goluckyvip.com/tag/36845.html
跨境派:https://www.goluckyvip.com/tag/36846.html
跨境派大师兄:https://www.goluckyvip.com/tag/36847.html
南京浦口都有什么好玩的地方 南京浦口都有什么好玩的地方推荐:https://www.vstour.cn/a/363180.html
永康白云风景区怎么走 白云山风景区怎么去??:https://www.vstour.cn/a/363181.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流