468,315 Members | 1,519 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,315 developers. It's quick & easy.

DataGrid - Delete Command Event Handler

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
2 2060
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
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.

Similar topics

reply views Thread by Curtis Hatter | last post: by
2 posts views Thread by Deepesh | last post: by
4 posts views Thread by Jeff User | last post: by
4 posts views Thread by drakuu | last post: by
9 posts views Thread by rn5a | last post: by
1 post views Thread by =?Utf-8?B?YW5u?= | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.