DataGrid - Delete Command Event Handler

Discussion in 'ASP .Net' started by Jim McGivney, Aug 3, 2005.

  1. Jim McGivney

    Jim McGivney Guest

    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
     
    Jim McGivney, Aug 3, 2005
    #1
    1. Advertising

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



    "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.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
    >
    >
    >
     
    =?Utf-8?B?RWx0b24gVw==?=, Aug 3, 2005
    #2
    1. Advertising

  3. Jim McGivney

    Jim McGivney Guest

    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" <> wrote in message
    news:...
    > 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
    >
    >
    >
    > "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.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
    >>
    >>
    >>
     
    Jim McGivney, Aug 4, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David A. Beck

    Event handler for multiple command buttons

    David A. Beck, Dec 4, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    350
    Chris Jackson
    Dec 4, 2003
  2. Sriram
    Replies:
    0
    Views:
    530
    Sriram
    Dec 4, 2003
  3. Alex
    Replies:
    2
    Views:
    598
  4. Alex
    Replies:
    1
    Views:
    1,792
    Rick Spiewak
    Apr 24, 2004
  5. Replies:
    1
    Views:
    754
    Damien
    Feb 22, 2007
Loading...

Share This Page