【发布时间】:2011-10-10 02:43:18
【问题描述】:
我有一个使用 SQL 数据库生成的表并放入 asp:Repeater 以显示数据。
表格显示良好,包含所有相关数据。万事如意!
但有时用户可能需要更改表格中的信息。我没有使用单独的页面甚至单独的部分供用户提交编辑,而是提出了一个想法,即让表格中的每个 CELL 成为一个文本框。并且在页面上,每个文本框的文本都设置为数据库值。
所以表格将显示并且完全相同,除了每个单元格都是可编辑的。但我无法让它工作。到目前为止我得到的是:
<asp:Repeater ID="rptPending" runat="server">
<HeaderTemplate>
<table id="tblPending" cellpadding="0" cellspacing="0" border="0" class="display">
<thead>
<tr>
<th>Company Name</th>
<th>Telephone</th>
<th>Fax Number</th>
<th>Address Line 1</th>
<th>Address Line 2</th>
<th>City</th>
<th>Postcode</th>
<th>Company User</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<form id="form" runat="server">
<tr>
<td><asp:TextBox ID="companyName" runat="server" AutoPostBack="true" Text="<%# Eval("_companyName") %>"></asp:TextBox></td>
<td><asp:TextBox ID="companyName" runat="server" AutoPostBack="true" Text="<%# Eval("_telephone")%>"></asp:TextBox></td>
<td><asp:TextBox ID="companyName" runat="server" AutoPostBack="true" Text="<%# Eval("_faxNo")%>"></asp:TextBox></td>
<td><asp:TextBox ID="companyName" runat="server" AutoPostBack="true" Text="<%# Eval("_addressLn1")%>"></asp:TextBox></td>
<td><asp:TextBox ID="companyName" runat="server" AutoPostBack="true" Text="<%# Eval("_addressLn2")%>"></asp:TextBox></td>
<td><asp:TextBox ID="companyName" runat="server" AutoPostBack="true" Text="<%# Eval("_city")%>"></asp:TextBox></td>
<td><asp:TextBox ID="companyName" runat="server" AutoPostBack="true" Text="<%# Eval("_postCode")%>"></asp:TextBox></td>
<td><asp:TextBox ID="companyName" runat="server" AutoPostBack="true" Text="<%# Eval("_name")%>"></asp:TextBox></td>
</tr>
</form>
</ItemTemplate>
<FooterTemplate>
</tbody> </table>
</FooterTemplate>
</asp:Repeater>
在旧方法中,在 [td] 标记之间,我实际上只有 语句。于是我把它改成了asp:Textbox标签。
我收到一条错误消息,提示服务器标签格式不正确。
如果有人知道解决方法或更好的方法,将不胜感激:)
附言没有对 asp:DataTable 或 GridView 的引用。我对它们不感兴趣。
【问题讨论】:
标签: html asp.net html-table