首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

datalist 实现评论 回复解决方案

2012-03-12 
datalist 实现评论 回复datalist 怎么实现评论的功能?我现在用一个datalist实现新闻的详细内容,html 与CS

datalist 实现评论 回复
datalist 怎么实现评论的功能? 

我现在用一个datalist实现新闻的详细内容,html 与CS的代码如下,想实现每个新闻有评论,并在同一个页面显示!!

问题1、怎样在datalist中实现回复框?

问题2、怎样显示在同一页面



HTML code
 
        <asp:DataList ID="DataList1" runat="server">
              <ItemTemplate> 
  <table border=1> 
  <tr> 
<td>ID: <%#  DataBinder.Eval(Container.DataItem,  "ID")  %> <td>
<tr>
    <td>
        用户ID: <%#  DataBinder.Eval(Container.DataItem,  "userid")  %>
        <td>
            <tr>
                <td>
                    标题: <%#  DataBinder.Eval(Container.DataItem,  "title")  %> </td>
            </tr>
            <tr>
                <td>
                    内容: <%#  DataBinder.Eval(Container.DataItem,  "content")  %>
                </td>
            </tr>
            <tr>
                <td>
                    bb: <%#  DataBinder.Eval(Container.DataItem,  "bb")  %>
                </td>
            </tr>
            <tr>
                <td>
                    aaa: <%#  DataBinder.Eval(Container.DataItem,  "aaa")  %>
                </td>
            </tr>

  </table> 
  </ItemTemplate>


[code=C#]




  if (Request.QueryString["ID"] != null)
  {
  SqlConnection conn = db.creatdb();

  string tosuID = Request.QueryString["ID"].ToString();

  SqlDataAdapter sda = new SqlDataAdapter();
  sda.SelectCommand = new SqlCommand("select * from feedback where ID=+'" + ID + "'", conn);
  DataTable dt = new DataTable();
  sda.Fill(dt);
  DataList1.DataSource = dt.DefaultView;
  DataList1.DataBind();

  }

[/code]

[解决办法]

<ItemTemplate>
<TABLE id="Table2" cellSpacing="4" cellPadding="0" border="0" style="FONT-SIZE: 9pt">
<TR>
<TD><br>
回复人:<%# DataBinder.Eval(Container, "")%>
回复时间:<%# DataBinder.Eval(Container, "")%>
 </TD>
</TR>
<TR>
<TD>内容:<%# DataBinder.Eval(Container, "")%></TD>


</TR>
</TABLE>
</ItemTemplate>
根据是否有回复显示
参考
http://www.cnblogs.com/xiaobaigang/archive/2007/07/19/824040.html
[解决办法]
在下面追加一个textbox不就可以了!

热点排行