Deleting multiple rows (Hotmail style datagrid)

Discussion in 'ASP .Net Datagrid Control' started by Darren, Jan 21, 2005.

  1. Darren

    Darren Guest

    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
    Darren, Jan 21, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?YSBkZXZlbG9wZXI=?=

    datagrid and multiple checkboxes(hotmail model)

    =?Utf-8?B?YSBkZXZlbG9wZXI=?=, Nov 6, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    526
    Olivier Verdin
    Nov 6, 2004
  2. Patrick.O.Ige
    Replies:
    0
    Views:
    666
    Patrick.O.Ige
    Nov 3, 2005
  3. Nazar
    Replies:
    0
    Views:
    433
    Nazar
    Aug 14, 2010
  4. Stephen Noronha

    Deleting Multiple Rows

    Stephen Noronha, Feb 19, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    154
    Marshal Antony
    Feb 20, 2004
  5. Paul D.Smith

    Hotmail popper - Hotmail => pop3 access <eom>

    Paul D.Smith, Oct 14, 2004, in forum: ASP General
    Replies:
    0
    Views:
    377
    Paul D.Smith
    Oct 14, 2004
Loading...

Share This Page