DataGrid - Delete Command Event Handler

J

Jim McGivney

I am using a Microsoft Book as a guide and trying to construct a Delete
Command Event Handler for a DataGrid.



The book lists the statement:

PublisherDataSet1.publishers.Rows.(e.Item.ItemIndex).Delete();



I try to follow the example. My code is:



private void DataGrid1_DeleteCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)

{

DataSet3.Ante.Rows.Item(e.Item.ItemIndex).Delete();

sqlDataAdapter1.Update(dataSet31);

DataGrid1.DataSource=dataSet31.Ante.DefaultView;

DataGrid1.EditItemIndex=-1;

DataGrid1.DataBind();

}



When I Build, I get the error message: System.Data.DataRowCollection does
not contain a definition for 'Item"



Any suggestions as to what I am doing wrong would be appreciated



Thanks,

Jim
 
G

Guest

Hi Jim,

in C#, it should be

dataset.Tables[table_name].Rows.Item[e.Item.ItemIndex].Delete();

or

dataset.Tables[table_index].Rows.Item[e.Item.ItemIndex].Delete();

HTH

Elton Wang
(e-mail address removed)
 

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

Top