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.

Showing Answers 1 - 4 of 4 Answers

SReenivasulu

  • 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

carl

  • Nov 12th, 2005
 

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

  Was this answer useful?  Yes

may

  • May 25th, 2006
 

how?

  Was this answer useful?  Yes

janardhan

  • May 3rd, 2007
 

Can you post example code about that Mr. srinu

Thanks 

  Was this answer useful?  Yes

ashrafali_002

  • Jun 11th, 2007
 

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

  Was this answer useful?  Yes

devendra

  • Sep 5th, 2007
 

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)

  Was this answer useful?  Yes

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.

Give your answer:

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

 

Related Answered Questions

 

Related Open Questions