我正在使用一个列表视图里面的项目模板中,我正在使用一个标签和一个复选框。 我希望每当用户点击复选框时,值应该在表中更新。我在listview.on中使用datakeys,datakey值的基础应该在表中更新。查询:如何在ASP.NET的ListView中的复选框的CheckedChanged事件上找到数据键?
string updateQuery = "UPDATE [TABLE] SET [COLUMN] = " + Convert.ToInt32(chk.Checked) + " WHERE PK_ID =" + dataKey + " ";`
我也想在显示结果的,因为它是table.means内,如果针对特定PKID在表列中的值是1,那么该复选框建议立即进行删除检查一些帮助。
这里是代码片段:
<asp:ListView ID="lvFocusArea" runat="server" DataKeyNames="PK_ID" OnItemDataBound="lvFocusArea_ItemDataBound">
<LayoutTemplate>
<table border="0" cellpadding="1" width="400px">
<tr style="background-color: #E5E5FE">
<th align="left">
Focus Area
</th>
<th>
Is Current Focused
</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td width="80%">
<asp:Label ID="lblFocusArea" runat="server" Text=""><%#Eval("FOCUS_AREA_NAME") %></asp:Label>
</td>
<td align="center" width="20%">
<asp:CheckBox ID="chkFocusArea" runat="server" OnCheckedChanged="chkFocusArea_CheckedChanged" AutoPostBack="true" />
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="background-color: #EFEFEF">
<td>
<asp:Label ID="lblFocusArea" runat="server" Text=""><%#Eval("FOCUS_AREA_NAME") %></asp:Label>
</td>
<td align="center">
<asp:CheckBox ID="chkFocusArea" runat="server" OnCheckedChanged="chkFocusArea_CheckedChanged" AutoPostBack="true" />
</td>
</tr>
</AlternatingItemTemplate>
<SelectedItemTemplate>
<td>
item selected
</td>
</SelectedItemTemplate>
</asp:ListView>
帮助我。
检查更新的答案 – 2010-06-18 10:48:25
这是必须的问题? – Subbu 2010-07-27 13:00:23
它不是强制性的,你必须接受,如果它的工作其他它可以我会删除我的答案在这种情况下 – 2010-08-11 07:13:16