Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Datagrid Control (http://www.velocityreviews.com/forums/f60-asp-net-datagrid-control.html)
-   -   Delete a DataGrid Row (http://www.velocityreviews.com/forums/t759750-delete-a-datagrid-row.html)

Eric 10-20-2003 06:13 PM

Delete a DataGrid Row
 
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 10-20-2003 06:52 PM

Re: Delete a DataGrid Row
 
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" <eric@askthepcpro.com> wrote in message
news:b41ad15c.0310201013.b517d6e@posting.google.co 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




Eric 10-20-2003 11:23 PM

Re: Delete a DataGrid Row
 
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:<uU7RQtzlDHA.708@TK2MSFTNGP10.phx.gbl>...
> 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


Raven Brooke 10-22-2003 04:04 PM

Re: Delete a DataGrid Row
 

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 10-23-2003 12:07 AM

Re: Delete a DataGrid Row
 
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" <brookr@mmc.org> wrote in message
news:uoSV9YLmDHA.2140@TK2MSFTNGP09.phx.gbl...
>
> 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!





All times are GMT. The time now is 02:23 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.