Delete a DataGrid Row

Discussion in 'ASP .Net Datagrid Control' started by Eric, Oct 20, 2003.

  1. Eric

    Eric Guest

    How can you delete a DataGrid item row? I found a couple threads on
    how to hide the row (using MyDataGrid.Items(n).Visible = False). This
    does work, but I need to physically remove the information from the
    grid, not just hide it. Any ideas?

    Thanks in advance,

    Eric
     
    Eric, Oct 20, 2003
    #1
    1. Advertising

  2. Eric

    Alvin Bruney Guest

    The datagrid retrieves its data from the underlying datasource which is
    usually a dataset. The simplest way is to just remove the row in the dataset
    and rebind the datagrid. If it is not in the dataset, it cannot possibly
    show up in the datagrid. You would need to first find the row to be deleted
    (from the selecteditem) and just do a find on the dataset and use the delete
    property of the dataset row to clean out the dataset.
    hth

    --


    -----------
    Got TidBits?
    Get it here: www.networkip.net/tidbits/default.htm

    "Eric" <> wrote in message
    news:...
    > How can you delete a DataGrid item row? I found a couple threads on
    > how to hide the row (using MyDataGrid.Items(n).Visible = False). This
    > does work, but I need to physically remove the information from the
    > grid, not just hide it. Any ideas?
    >
    > Thanks in advance,
    >
    > Eric
     
    Alvin Bruney, Oct 20, 2003
    #2
    1. Advertising

  3. Eric

    Eric Guest

    Thank you, Alvin...a perfect, simple suggestion. (Why didn't I think of that!?)

    Thanks again,

    Eric

    "Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com> wrote in message news:<>...
    > The datagrid retrieves its data from the underlying datasource which is
    > usually a dataset. The simplest way is to just remove the row in the dataset
    > and rebind the datagrid. If it is not in the dataset, it cannot possibly
    > show up in the datagrid. You would need to first find the row to be deleted
    > (from the selecteditem) and just do a find on the dataset and use the delete
    > property of the dataset row to clean out the dataset.
    > hth
    >
    > --
    >
    >
    > -----------
    > Got TidBits?
    > Get it here: www.networkip.net/tidbits/default.htm
     
    Eric, Oct 21, 2003
    #3
  4. Eric

    Raven Brooke Guest

    This was my first thought also, but what is the syntax for finding the
    row in the datasource? I get as far as:

    ds.Tables["dt"].Rows.Remove(what goes here?)

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Raven Brooke, Oct 22, 2003
    #4
  5. Eric

    Alvin Bruney Guest

    the argument takes a datarow object
    here is a quick example

    DataRow foundRow = myDataRowCollection.Find(lblID.Text)
    if(foundRow != null)
    myDataRowCollection.Remove(foundRow)

    regards
    --


    -----------
    Got TidBits?
    Get it here: www.networkip.net/tidbits
    "Raven Brooke" <> wrote in message
    news:...
    >
    > This was my first thought also, but what is the syntax for finding the
    > row in the datasource? I get as far as:
    >
    > ds.Tables["dt"].Rows.Remove(what goes here?)
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Alvin Bruney, Oct 23, 2003
    #5
    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. Alex
    Replies:
    1
    Views:
    1,783
    Rick Spiewak
    Apr 24, 2004
  2. JenHu
    Replies:
    6
    Views:
    5,237
    =?Utf-8?B?UGF1bCBK?=
    Feb 3, 2005
  3. =?Utf-8?B?U2hhd24=?=

    Magic Trick Datagrid Delete Row

    =?Utf-8?B?U2hhd24=?=, Apr 6, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,463
    =?Utf-8?B?U2hhd24=?=
    Apr 6, 2005
  4. Fred Zolar
    Replies:
    0
    Views:
    223
    Fred Zolar
    Apr 1, 2004
  5. D
    Replies:
    0
    Views:
    223
Loading...

Share This Page