Deleting multiple rows (Hotmail style datagrid)

D

Darren

Hey folks,

I have an application that needs to delete multiple datagrid rows (Hotmail
style). I modeled mine after the article at http://aspalliance.com/427

Here is my delete button click event logic:

private void btnDelete_Click(object sender, System.EventArgs e)
{
CheckBox chk = null;
bool chkSelected = false;
foreach (DataGridItem item in dgNew.Items)
{
if (item.ItemType != ListItemType.Header && item.ItemType !=
ListItemType.Footer && item.ItemType != ListItemType.Pager)
{
chk = (CheckBox)item.Cells[0].FindControl("chkSelect");
chkSelected = chk.Checked;
if (chkSelected)
{
int appId = Convert.ToInt32(dgNew.DataKeys[item.ItemIndex].ToString());
sqlCommand1.Parameters["@AppId"].Value = appId;
sqlConnection1.Open();
sqlCommand1.ExecuteNonQuery();
sqlConnection1.Close();
}
}
}

dgNew.EditItemIndex = -1;
BindGrid();
}

The problem is that even though I have some of the checkboxes checked, when
I step into this event, it reports that all checkboxes are NOT checked. Is
there something I am missing?

Thanks,

Darren
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top