GeekInterview.com
Series: Subject: Topic:
Question: 14 of 14

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.

Asked by: Interview Candidate | Asked on: Jun 29th, 2005
Showing Answers 1 - 8 of 8 Answers
SReenivasulu

Answered On : Jun 29th, 2005

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

Yes  1 User has rated as useful.
  
Login to rate this answer.
carl

Answered On : Nov 12th, 2005

So Does that mean we can not stop datagrid displaying an empty row at runtime?

  
Login to rate this answer.
sahu

Answered On : Jan 27th, 2006

View all questions by sahu   View all answers by sahu

yes,

definitely, we can add row one by one

  
Login to rate this answer.
may

Answered On : May 25th, 2006

how?

  
Login to rate this answer.
janardhan

Answered On : May 3rd, 2007

Can you post example code about that Mr. srinu

Thanks

  
Login to rate this answer.
ashrafali_002

Answered On : Jun 11th, 2007

Yes,
Just apply same code for data load in Datagrid after Save.

  
Login to rate this answer.
devendra

Answered On : Sep 5th, 2007

Example
dim da as new sqldataadapter("select...",conn)
dimdsas 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)

  
Login to rate this answer.
Dipali Shah

Answered On : Sep 4th, 2008

View all answers by Dipali Shah

Yes, you can add rows one by one at runtime. for thatyou 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 rowto table you have to maintain its state.
ViewState["Temp"]=(DataTable)dt;

dg.DataSource=(DataTable)ViewState["Temp"];

and going on.

Thanks.

Yes  1 User has rated as useful.
  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.