Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspdotnet_website_programming thread: Delete multiple rows using multiple checkboxes (in a Datagrid) and one Delete button


Message #1 by Romy Jarr <romyjarr@t...> on Tue, 29 Oct 2002 23:05:39 +0800
...Hi guys,

...How can I do deletion of multiple rows (with one checkbox for every rows) inside a datagrid by clicking one command button i.e.
Delete button? This 'Delete' button is placed outside the datagrid together with 'Select All' and 'Clear All'.  I know how to code
the function for both 'Select All' and 'Delete All', but not the 'Delete' one.  The user shall select/check any checkboxes for any
rows...once he/she click at the 'Delete' button, all the selected/checked records will be deleted from the database.  This
functionality works sort of like in Hotmail/Yahoo Mail fashion.  I am aware of http://www.datagridgirl.com/rowselector.aspx, I can't
seem to get this to work the way I want it.  Can anyone point me to this implementation?

...The below code snippet is the method definition when the user want to delete a particular row by clicking at the delete icon for
the respective row.  This is set using the datagrid attribute namely OnDeleteCommand="NewsGrid_Delete":

protected void NewsGrid_Delete(object sender, DataGridCommandEventArgs e)
{
    UnselectGridItem( );
    // delete the news identified by the ID of this row
    NewsMailer.NewsHistoryDB news = new NewsMailer.NewsHistoryDB(GetConnString());
    news.Delete( (int)NewsGrid.DataKeys[e.Item.ItemIndex] );
    BindGrid( );
}

...The DayaKeyField for the datagrid (i.e. NewsGrid) is the ID of each record.

...Thanks in advance for the help.

...Kindly regards,
Romy
Petronas Twin Tower (KLCC),
Kuala Lumpur,
...Malaysia....


  Return to Index