接触asp.net一段时间了,被Codebehind技术深深吸引。但是我有个疑问:比如做个留言板,一条记录如下所示------------------------------------
留言时间 留言姓名留言内容(因为很长,故单独放一行)
------------------------------------这个时候就不好用Datagrid了。如果像asp那样,很容易实现。我只要把这个表格放在while 和 End while之间就可以了。但是我想用CodeBehind,请各位有经验的大虾告诉我一个解决思路,不胜感谢。
留言时间 留言姓名留言内容(因为很长,故单独放一行)
------------------------------------这个时候就不好用Datagrid了。如果像asp那样,很容易实现。我只要把这个表格放在while 和 End while之间就可以了。但是我想用CodeBehind,请各位有经验的大虾告诉我一个解决思路,不胜感谢。
留言时间 留言姓名留言内容(因为很长,故单独放一行)
------------------------------------这个照样可以用DataGrid,呵呵你可以做一个模版列,然后往模版列里写代码:
<table>
<tr><td>留言时间</td><td>留言姓名</td></tr>
<tr><td>内容...</td></tr>
</table>
这样明白了吗?
<Columns>
<asp:TemplateColumn HeaderText="选择名字可以直接回复">
<ItemStyle Width="100%"></ItemStyle>
<ItemTemplate>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="2bit">
<tr>
<td valign="middle" height="25"><b><font color="DarkSlateGray">
<asp:Label ID="Sender_" Text='<%# DataBinder.Eval(Container, "DataItem.SenderTName") %>' Runat=server/></b>
<%# DataBinder.Eval(Container, "DataItem.SendTime") %></td>
<td width="100" align="right"></td></tr>
<tr><td colspan="2"> <asp:Label ID="ID_" Text='<%# DataBinder.Eval(Container, "DataItem.ID") %>' Visible=False Runat=server/>
<%# htmlstring(DataBinder.Eval(Container, "DataItem.Contents")) %></td>
</tr>
<tr>
<td align="right" colspan="2">
<hr color="DarkSlateGray" size="1"> <asp:LinkButton ID="Linkbutton4" Text="回复" CommandName="Select" Runat="server" /> <asp:LinkButton ID="LinkButtonX" Text="删除" CommandName="Delete" Runat="server" />
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>