473,387 Members | 1,497 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 2290
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Stephen | last post by:
I have got an event below to remove items from an arraylist and then to rebind the arraylist to the datagrid subsequently deleting the appropriate row. My problem is that my code makes sense and I...
0
by: Curtis Hatter | last post by:
I apologize if this has been answered, but on the .NET 247 site I saw a thread titled "Datagrid's ItemCommand Event", and had similar troubles with the Datagrid not properly firing the delete event...
4
by: Rod | last post by:
I posted a message to this group yesterday asking how to pass parameters to a web form that is the source of an IFrame on a parent web form. I've gotten my answer, and it works. Thanks! Now I...
2
by: Deepesh | last post by:
Good day, I have a specific case of the DataGrid in my solution which is causing the ItemCommand Event Not Firing. So I'm creating a "Skinnable" set of controls. I seperate the actual ASCX file...
4
by: Jeff User | last post by:
Hi I tryed to solve this problem over in the framework.asp group, but still am having trouble. Hope someone here can help. using .net 1.1, VS 2003 and C# I have an asp.DataGrid control with a...
4
by: drakuu | last post by:
Hello there, I have DataGrid with some records and I would like to edit it right in the datagrid using the built in commands. I can't figure out a way to pass to the SQL query the record ID...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
10
by: amiga500 | last post by:
Hello, I have one basic simple question. When I have multiple records in the datagrid as follows: Code Product 1 Product 2 Product 3 11111 A B C...
1
by: =?Utf-8?B?YW5u?= | last post by:
I am using a dynamic datagrid and want to add the "delete" command,but no matter what I try I cannot get it to work. This is what I have: ButtonColumn del = new ButtonColumn(); del.Text =...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.