In my grid view I've a checkbox column, and am binding the gridview with a dictionary. I need to get the corresponding Id from the checked boxes.
In my dictionary I've the key values like
Id Name
-- ----
1 Arts
2 Science
3 Engineering
Here, I tried to bind the value for this checkbox as
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkSelItem" value="<%# Eval("Key.Id") %>"
runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Department">
<ItemTemplate>
<%# Eval("Key.Name") %>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
and from the codebehind, I tried like
foreach (GridViewRow row in gridDepartments.Rows)
{
CheckBox chkSelItem = (CheckBox)row.FindControl("chkSelItem");
if (chkSelItem.Checked)
{
int departmentId = int.Parse(chkSelItem.Text);
////
////
}
}
its throwing error, or not showing any value for the checkbox.
I also trid with FindControl, but no use of it, coz in the key & Value pair am using a class(which inherits another class) and a bool. thats what am trying like this, can anyone help me here, thanks in advance.....
deletebutton, I've to get the correspondingIds and delete the values from the database