GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  DataGrid
Next Question 
 DataGrid  |  Question 1 of 14    Print  
In DataGrid, is it possible to add rows one by one at runtime. That means after entering data in one row next row will be added.

  
Total Answers and Comments: 8 Last Update: September 04, 2008   
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: SReenivasulu
 
Yes, for this you have to use datatable and after inserting the first row in datatable u have to bind that datatable to the grid and next time , first u have to add the row in datatable and next bind it to datagrid. keep on doing.  
u have to maintain the datatable state. 
happy coding 
 
bye 
srinu

Above answer was rated as good by the following members:
narayanasreekanth, palaniyammal
June 29, 2005 09:58:40   #1  
SReenivasulu        

RE: In DataGrid, is it possible to add rows one by one at runtime. That means after entering data in one...
Yes for this you have to use datatable and after inserting the first row in datatable u have to bind that datatable to the grid and next time first u have to add the row in datatable and next bind it to datagrid. keep on doing.
u have to maintain the datatable state.
happy coding

bye
srinu

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
November 12, 2005 22:12:08   #2  
carl        

RE: In DataGrid, is it possible to ad...
So Does that mean we can not stop datagrid displaying an empty row at runtime?
 
Is this answer useful? Yes | No
January 27, 2006 09:49:43   #3  
sahu Member Since: December 2005   Contribution: 323    

RE: In DataGrid, is it possible to ad...

yes

definitely we can add row one by one


 
Is this answer useful? Yes | No
May 25, 2006 05:39:33   #4  
may        

RE: In DataGrid, is it possible to ad...
how?
 
Is this answer useful? Yes | No
May 03, 2007 01:39:23   #5  
janardhan        

RE: In DataGrid, is it possible to ad...
Can you post example code about that Mr. srinu

Thanks

 
Is this answer useful? Yes | No
June 11, 2007 16:59:31   #6  
ashrafali_002        

RE: In DataGrid, is it possible to ad...
Yes
Just apply same code for data load in Datagrid after Save.

 
Is this answer useful? Yes | No
September 05, 2007 11:52:19   #7  
devendra        

RE: In DataGrid, is it possible to ad...
Example
dim da as new sqldataadapter( select... conn)
dim ds as new dataset
da.fill(ds xyz)
dim dr as datarow
dr ds.tables(0).rows.newrow
with dr
.items(0) textbox1.text
.items(1) textbox2.text
.items(2) textbox3.text
ds.tables(0).addrow(dr)

datagrid1.datasource ds.tables(0)

 
Is this answer useful? Yes | No
September 04, 2008 07:28:34   #8  
Dipali Shah Member Since: August 2008   Contribution: 3    

In DataGrid, is it possible to add rows one by one at runtime. That means after entering data in one row next row will be added.
Yes you can add rows one by one at runtime. for that you have to maintain DataTable and its ViewState. So after pageload data is not removed from datatable.

For display purpose you have to bind that datatable to grid.

for. exp;

Each and every time after adding row to table you have to maintain its state.
ViewState[ Temp ] (DataTable)dt;

dg.DataSource (DataTable)ViewState[ Temp ];

and going on.

Thanks.

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape