DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   C# (http://www.daniweb.com/forums/forum61.html)
-   -   How to add a new row to a datagrid (http://www.daniweb.com/forums/thread124048.html)

menelaussa May 13th, 2008 12:39 pm
How to add a new row to a datagrid
 
Hi,
Can anybody help me to add a blank row into a datagrid?
Thank you!

olibara May 13th, 2008 5:22 pm
Re: How to add a new row to a datagrid
 
DGV.Rows.add();

But if the datagrid is binded you need to add the row to the datasource, NOT in the DGV

DataTable.rows.add();

olibara May 13th, 2008 5:23 pm
Re: How to add a new row to a datagrid
 
DGV.Rows.add();
But if the datagrid is binded you need to add the row to the datasource, NOT in the DGV

DataTable.rows.add();

majestic0110 May 13th, 2008 5:25 pm
Re: How to add a new row to a datagrid
 
Could I enquire as to why you would want to do this? Give this a try:

Quote:

datagrid1.Rows.Add(new object[]{null,null});

I am not sure if this will work but give it a try - let me know how it goes!

menelaussa May 14th, 2008 4:57 am
Re: How to add a new row to a datagrid
 
Thank you to all for your answers.
My datagrid is binded to an object.
I am adding an new empty collection to the object before to bind it to the datagrid.
I have a new empty row into my datagrid, but now the problem is that the id the item is null and I cannot update or delete it.

Can you help me with that?

Thank you!

menelaussa May 14th, 2008 6:09 am
Re: How to add a new row to a datagrid
 
Hooraay , I added a new object on Update and Delete procedures and now it works fine.
Thank you for your replay!

olibara May 14th, 2008 6:21 am
Re: How to add a new row to a datagrid
 
What object ?
What Id
What code

Difficult to say anything without a little more details ..

sanjayNawab May 15th, 2008 8:23 am
Re: How to add a new row to a datagrid
 
Set the all property of datagrid

o_shawky May 19th, 2008 4:59 am
Re: How to add a new row to a datagrid
 
BindingContext[datasetname,"table"].newrow();


All times are GMT -4. The time now is 11:43 pm.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC