GridView中嵌套Repeater方法
2009-01-20 09:50
337 查看
前台代码如下: <asp:GridView ID="GridView2" runat="server" AllowPaging="True" OnPageIndexChanging="GridView2_PageIndexChanging" PageSize="5" AutoGenerateColumns="False" OnRowDataBound="GridView2_RowDataBound" Width="100%" CellPadding="0" ForeColor="#333333" GridLines="None" HorizontalAlign="Center"> <Columns> <asp:TemplateField> <ItemTemplate> <table border="0" cellpadding="0" cellspacing="1" width=100% style="background-color: #006699; border-right-style: none; border-left-style: none;" mce_style="background-color: #006699; border-right-style: none; border-left-style: none;"> <tr><td> <table border="0" cellpadding="0" cellspacing="0" class="listtable"> <tr><td style="font-weight: bold; color: white; text-align: left;" mce_style="font-weight: bold; color: white; text-align: left;"> <%# Eval("Bug_title")%></td></tr> <tr> <td bgcolor="#FFFFFF" style="padding:10px; text-align: left;" mce_style="padding:10px; text-align: left;"><%# Eval("BUG_Content")%> <%--嵌套一个Repeater5--%> <asp:Label ID="lbl_IDD" runat="server" Text='<%# Eval("bug_ID") %>' Visible="False"></asp:Label> <asp:Repeater ID="Repeater5" runat="server"> <ItemTemplate> <%-- <hr width="100%" size="1" color="#CCCCCC">--%> <fieldset><legend> <strong><%# BR_Name(Eval("BR_user_id"))%>回复:</strong></legend><span class="Reply"><%# Eval("BR_content")%></span> <div style="text-align: right;" mce_style="text-align: right;"><%# Eval("BR_cate")%> <%# string.Format("{0:yyyy}-{0:MM}-{0:dd}", Eval("BR_adddate"))%> </div> </fieldset> </ItemTemplate> </asp:Repeater> <%--end--%> </td> </tr> <tr> <td bgcolor="#FFFFFF" style="padding:4px; border-top: white thin solid;" mce_style="padding:4px; border-top: white thin solid;"> <ul class="bottomUl"> <li style="background:url(../images/1_r12_c14.jpg) no-repeat; width: 100px; position: static;">:<%# string.Format("{0:yyyy}-{0:MM}-{0:dd} {0:HH}:{0:mm}", Eval("Bug_adddate"))%></li> <li style="background:url(../images/1_r12_c15.jpg) no-repeat; width: 80px; position: static;">:<%# Software_Name(Eval("Bug_sw_ID"))%></li> <li style="background:url(../images/1_r12_c15.jpg) no-repeat; width: 80px; position: static;">:<%# Software_edition(Eval("Bug_Pro_ID"))%></li> <li style="background:url(../images/1_r12_c16.jpg) no-repeat;" mce_style="background:url(images/1_r12_c16.jpg) no-repeat;">:<%# Eval("Bug_grade")%></li> <li style="background:url(../images/1_r12_c16.jpg) no-repeat;" mce_style="background:url(images/1_r12_c16.jpg) no-repeat;">:<%# Eval("Bug_ok")%></li></ul> </tr> </table> </td></tr></table> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> 后台代码如下: private void BindGridView2() { sqlStr2 = "select * from bug where bug_pro_id='" + Request.QueryString["id"] + "' order by bug_adddate desc"; SqlDataAdapter myCommand = new SqlDataAdapter(sqlStr2, conn); DataSet ds = new DataSet(); myCommand.Fill(ds, "Authors"); GridView2.DataSource = ds.Tables["Authors"].DefaultView; GridView2.DataBind(); } protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e) { this.GridView2.PageIndex = e.NewPageIndex; BindGridView2(); } protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Repeater Repeater5_CS = null; Label PD_IDD_CS = new Label(); Repeater5_CS = (Repeater)e.Row.FindControl("Repeater5"); if (Repeater5_CS != null) { PD_IDD_CS = (Label)e.Row.FindControl("lbl_IDD"); if (PD_IDD_CS != null) { string PD_IDD = PD_IDD_CS.Text.ToString(); SqlDataAdapter sda = new SqlDataAdapter("select * from BugReply where BR_Bug_ID='" + PD_IDD + "'", conn); DataSet ds = new DataSet(); sda.Fill(ds, "table"); Repeater5_CS.DataSource = ds.Tables["table"].DefaultView; Repeater5_CS.DataBind(); } } } }
注:区别如下
GridView中嵌套Repeater方法:protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e){}
Repeater中嵌套Repeater方法:protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e){}
相关文章推荐
- checkbox嵌套在repeater,gridview中的全选/反选(方法总结)
- GridView、ListView、Repeater使用方法
- ScrollView嵌套GridView方法
- ScrollView下嵌套GridView或ListView默认不在顶部的解决方法
- 操作GridView嵌套的Repeater控件
- ListView 里面嵌套 GridView 遇到的问题及其解决方法。
- android 开发listview,gridview,scroolview之间的嵌套,出现子view显示不完整解决方法
- Repeater中嵌套Repeater方法
- ListView嵌套GridView出现的问题及解决方法
- net 2.0中的Repeater嵌套 的两种方法
- net 2.0中的Repeater嵌套 的两种方法
- android中ListView中嵌套GridView并且把GridView当中的内容全部显示出来的方法
- 将repeater、datalist、gridview中的数据导出到Excel中的简单方法
- 关于ScrollView中嵌套GridVIew只显示一行解决方法以及GridView行高计算方法
- Android ListView嵌套GridView方法
- 动态列的GridView嵌套解决方法整理
- ListView嵌套GridView显示不全解决方法
- gridview 外嵌套HorizontalScrollView 横向滑动后setselection(position)不起作用的解决方法
- listview gridview屏蔽滑动及嵌套时解决方法
- ListView嵌套GridView显示不全解决方法