Hi all, I have checkboxes in datagrid to select and a delete button outside the datagrid to delete the checked row in datagrid. After checking the check box and clicking the delete button, in the btndelete_Click im finding the check box in the datagrid and deleting the particular record, but im getting the checked false in the btndelete_Click of the datagrid checkbox which is checked. Please tell me why it is so and how can i find the checkbox of datagrid is checked or not in button click. The code is below:
protected void btnDelete_Click(object sender, EventArgs e)
{
foreach (DataGridItem DemoGridItem in grid.Items)
{
CheckBox oCheckbox = (CheckBox)DemoGridItem.Cells[1].FindControl("chkDelete");
HiddenField hidImageName = (HiddenField)DemoGridItem.Cells[1].FindControl("hdnItem");
if (oCheckbox.Checked == true)
{
try
{
Delete code;
}
catch( Exception e)
{
}
}
}
}
Thanks in advance for ur help.