现在要在页面中实现留言功能,一条留言可以有多条回复,一页显示多条留言是不是用REPEATER来生成表格得行,每行有一条留言,之后后面跟随得多条回复只能用for循环在aspx文件中直接写,就像asp一样,还是说REPEATER能嵌套REPEATER。如果可以,那么又怎么绑定数据呢?我不想在aspx文件中又这样的脚本代码,希望全部后代码方式,那么又什么解决方法呢?Thx!
调试欢乐多
<ItemTemplate>
<tr bgcolor="#FFD780">
<td width="20" bgcolor="#FFFFFF"> </td>
<td width="33%">评论人:<b><%# (string)DataBinder.Eval(Container.DataItem, "UserName")%></b></td>
<td>电子邮件:<b><%# HttpContext.Current.Server.HtmlEncode((string)DataBinder.Eval(Container.DataItem, "email")).Replace("@","@").Replace(".",".") %></b></td>
<td width="33%">评论日期:<%# DataBinder.Eval(Container.DataItem, "CreateDate","{0:yyyy年MM月dd日 hh:mm:ss}") %></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="20" bgcolor="#FFFFFF"> </td>
<td colspan="3"><%# DataBinder.Eval(Container.DataItem, "Content").ToString().Replace("\r\n","<br>").Replace(" "," ") %></td>
</tr>
<tr bgcolor="#f46240">
<td width="20" bgcolor="#FFFFFF" height="1"></td>
<td colspan="3" height="1"></td>
</tr>
</ItemTemplate>
<HeaderTemplate>
<table border="0" cellpadding="2" cellspacing="1" align="center" bgcolor="" width="100%"
style="word-wrap:break-word;word-break:break-all;font-size:9pt">
<tr bgcolor="#FF9801">
<td colspan="4"><b> 本文评论(Comments):</b>为了保护您的电子邮件不被骚扰,地址中的个别符号转换成了全角字符!</td>
</tr>
</HeaderTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
http://support.microsoft.com/default.aspx?scid=kb;EN-US;306154
strSQL = "SELECT * FROM Comments";
cmd.CommandText = strSQL;
ShowComments.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection);
ShowComments.DataBind();
留言1
回复1
回复2
留言2
回复1
回复2
回复3如果这样做的话,势必要出现两个结果集,这样如果只用repeater的话不就一定会出现嵌套了吗?