repeater嵌套不起作用
在网上查了个repeater嵌套的代码,我改做了留言簿嵌套留言回复用,但运行的时候只显示留言部分,回复的部分不显示,求教!
protected void msgRepeater_I器temDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater Reply_Repeater = (Repeater) e.Item.FindControl("Reply_Repeater");
//找到留言Repeater关联的数据项
DataRowView rowv = (DataRowView)e.Item.DataItem;
//提取留言ID
int Id = Convert.ToInt32(rowv["Msg_ID"]);
//绑定留言回复Repeater
SqlDataAdapter ada = new SqlDataAdapter("select * from Message_Reply where Msg_ID=" + Id,myconn);
DataSet ds = new DataSet();
myconn.Open();
ada.Fill(ds,"Message_Reply");
Reply_Repeater.DataSource =ds.Tables["Message_Reply"];
Reply_Repeater.DataBind();
myconn.Close();
}
}
.ASPX部分
<asp:Repeater ID="msgRepeater" runat="server">
<ItemTemplate>
<table border="0" cellpadding="0" cellspacing="0" style="width:650px; font-family:宋体; font-size:small">
<tr>
<td style="width:60px">
<img src='Face/<%#DataBinder.Eval(Container.DataItem,"Face_ID") %>.bmp' />
</td>
<td style="width:550px; vertical-align:top; font-size:16px" align="left">
昵称:<%#DataBinder.Eval(Container.DataItem,"Msg_User") %>
邮件地址:<%#DataBinder.Eval(Container.DataItem,"Msg_email") %>
</td>
<td style="width:40px">
#<%#DataBinder.Eval(Container.DataItem,"Msg_ID") %>
</td>
</tr>
<tr>
<td style="width:60px">
</td>
<td style="width:550px" align="left" colspan="2">
<%#DataBinder.Eval(Container.DataItem,"Msg_Content") %>
</td>
</tr>
<tr>
<td style="width:60px"></td>
<td style="width:550px">
<asp:Repeater ID="Reply_Repeater" runat="server">