Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Delete a DataGrid Row

Reply
Thread Tools

Delete a DataGrid Row

 
 
Eric
Guest
Posts: n/a
 
      10-20-2003
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
 
Reply With Quote
 
 
 
 
Alvin Bruney
Guest
Posts: n/a
 
      10-20-2003
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: m...
> 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



 
Reply With Quote
 
 
 
 
Eric
Guest
Posts: n/a
 
      10-20-2003
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

 
Reply With Quote
 
Raven Brooke
Guest
Posts: n/a
 
      10-22-2003

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!
 
Reply With Quote
 
Alvin Bruney
Guest
Posts: n/a
 
      10-23-2003
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!



 
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
ok I can do a totals row but how about a percentage row after each data row D ASP .Net Datagrid Control 0 05-23-2005 04:10 PM
Add row under selectedindex row of datagrid ujjc001@gmail.com ASP .Net 0 12-15-2004 12:01 AM
Add row under selectedindex row of datagrid ujjc001@gmail.com ASP .Net 0 12-15-2004 12:00 AM
How to add a new row to a datagrid with values of the selected row =?Utf-8?B?U3VyZXNo?= ASP .Net 1 11-22-2004 09:04 AM
Referencing Dataset row not Datagrid row Craig ASP .Net 2 11-02-2004 05:27 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57