在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
Repeater嵌套Repeater的结构:一般写过的都能看懂吧 private void RpTypeBind() { //GetQuestionTypeAndCount() 返回一个datatable this.rptypelist.DataSource = LiftQuestionCtr.GetQuestionTypeAndCount(); this.rptypelist.DataBind(); } protected void rptypelist_ItemDataBound(object sender, RepeaterItemEventArgs e) { //判断里层repeater处于外层repeater的哪个位置( AlternatingItemTemplate,FooterTemplate, //HeaderTemplate,,ItemTemplate,SeparatorTemplate) if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Repeater rep = e.Item.FindControl("rpquestionlist") as Repeater;//找到里层的repeater对象 DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 int typeid = Convert.ToInt32(rowv["qtid"]); //获取填充子类的id rep.DataSource = LiftQuestionCtr.GetSomeQuestionsByTypeid(typeid, 2); rep.DataBind(); } }
<table border="0" cellpadding="0" cellspacing="0" style="margin-bottom: 5px" width="100%"> <asp:Repeater runat="server" ID="rptypelist" OnItemDataBound="rptypelist_ItemDataBound"> <ItemTemplate> <tr> <td class="fb"> <a href="Lists.aspx?Qtid=<%#Eval("qtid") %>"><%#Eval("qtypename") %></a> <span class="date2">[<%#Eval("typecount")%>]</span> </td> </tr> <tr> <td> <div > <asp:Repeater runat="server" ID="rpquestionlist"> <ItemTemplate> <a href="Question.aspx?qid=<%#Eval("liftquestionid")%>"> <%#Eval("questiontitle")%></a><br /> </ItemTemplate> </asp:Repeater> </div> </td> </tr> </ItemTemplate> </asp:Repeater> </table>
|
请发表评论