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)
 
J

Jim McGivney

Elton:
I tried as you suggested:
dataSet31.Tables["ante"].Rows.Item(e.Item.ItemIndex).Delete();
I still got the same error message:
System.Data.DataRowCollection does not contain a definition for 'Item"
Any ideas ?
Jim




Elton W said:
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)


Jim McGivney said:
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
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top