Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DataGrid - Delete Command Event Handler

Reply
Thread Tools

DataGrid - Delete Command Event Handler

 
 
Jim McGivney
Guest
Posts: n/a
 
      08-03-2005
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


 
Reply With Quote
 
 
 
 
=?Utf-8?B?RWx0b24gVw==?=
Guest
Posts: n/a
 
      08-03-2005
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
http://www.velocityreviews.com/forums/(E-Mail Removed)


"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
>
>
>

 
Reply With Quote
 
 
 
 
Jim McGivney
Guest
Posts: n/a
 
      08-04-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 Removed)
>
>
> "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
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Event Handler that creates adds another event handler kaczmar2@gmail.com ASP .Net 1 02-22-2007 07:37 AM
Best way to get row data in a DataGrid delete handler Alex ASP .Net 1 04-24-2004 02:49 AM
Problem with Delete and Edit button in Datagrid - will not reach handler Alex ASP .Net 2 04-22-2004 09:57 PM
Dynamic control array & Command Event Handler Sriram ASP .Net 0 12-04-2003 08:47 PM
Event handler for multiple command buttons David A. Beck ASP .Net 2 12-04-2003 07:31 PM



Advertisments