Click here to Skip to main content
15,908,581 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,

I have bind the data table with 5 rows dynamically to a gridview.
Girdview consists of 3 dropdownlists and 4 textboxes.
I need to maintain the data in the gridview at roundtrip to the server.
I have kept gridview in update panel.

I have functionality that I need to add new row to the gridview.

At this time I am unable to maintain the data of first 5 rows in gridview.

I have tried in google also, I couldn't get the solution

Please help me in solving the issue
Posted

I think you are looking for some thing like this one: Dynamically adding and deleting rows from ASP.NET GridView[^]
 
Share this answer
 
Comments
VICK 24-Oct-13 7:44am    
MY 5 + :)
Thanks7872 24-Oct-13 7:48am    
Thanks. :-)
Initially your gridview is having datatable with 5 rows.
and You want to add 6th row in it?? Right??

do the following.

Add the 5row datatable in ViewState.

in the code where you want to add sixth row.

Create another datatable. get the 5row datatable through viewstate in it.

create a new datarow for this new datatable.

add it in to it.

now new datatable will be having 6 rows.

rebind your gridview with this new datatable and also save this in ViewState.

EDIT: Further Kindly have a look at the other solution posted by Rohan... It is pretty detailed working code with it and I think that would solve your problem. :)


Hope it will help. :)
 
Share this answer
 
v2
Comments
sri4dotnet 24-Oct-13 7:40am    
I have done this but the data in dropdownlist is fetched from database and is bind to it.
when I add new row, in viewstate the values of the dropdownlist are not maintained
VICK 24-Oct-13 7:44am    
in viewstate the values of the dropdownlist are not maintained???

for the new created row or for the previous ones???
sri4dotnet 12-Nov-13 8:11am    
Previous ones

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900