By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,905 Members | 1,616 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,905 IT Pros & Developers. It's quick & easy.

DataGrid - Delete Command Event Handler

P: n/a
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.ItemInde x).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
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
el********@hotmail.com
"Jim McGivney" wrote:
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.ItemInde x).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

Nov 19 '05 #2

P: n/a
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" <El****@discussions.microsoft.com> wrote in message
news:7D**********************************@microsof t.com...
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
el********@hotmail.com
"Jim McGivney" wrote:
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.ItemInde x).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

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.