I am binding some data from remoter server database to my listview. I have made one column to select the row with checkbox & on button click I want to update status of those selected rows. Problem is the code which I am using is not able to find checkbox control inside listview & which resulting unable to select rows.
I have set checkbox tooltip to row ID to get selected ID of row. Listview gets bind perfectly with checkbox control inside. When put a breakpoint I noticed that 'IF' condition (if (item is CheckBox)) is not getting true hence it unable to run further code.
List<string> ListItems = new List<string>();
foreach (void el_loopVariable in shipments.Items) {
el = el_loopVariable;
foreach (void item_loopVariable in el.Controls) {
item = item_loopVariable;
if (item is CheckBox) {
if (((CheckBox)item).Checked == true) {
ListItems.Add(((CheckBox)item).ToolTip);
Session["selectedConsignments"] = ListItems.ToArray();
}
}
}
}
Listview (For simplicity I am just putting one column of that checkbox)
<asp:ListView ID="shipments" runat="server" DataKeyNames="ID">
<ItemTemplate>
<tr>
<td id="cell13" runat="server">
<asp:CheckBox ID="chk" runat="server" ToolTip='<%# Eval("ID") %>' />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
voiddo in foreach loop.