1
Answer

Dynamic Template control and value persistence

Shiva Nandan

Shiva Nandan

15y
3k
1

Hi friends
I have created a gridview using ITemplate to generate textboxes in cells and to display the data. The grid is bound using a datatable in PreRender event.
On Page refresh the modified value gets replaced by the existing value from datatable. If I do not bind the gridview in each refresh, the textboxes  gets vanish from the gridview.
Can any one help me to overcome this problem.
Does viewstate will have any role in this?
Thanks in advance
Answers (1)
0
Suthish Nair

Suthish Nair

NA 31.7k 4.6m 14y

Use Linq to datatable, refer sample.
DataTable dtMain = new DataTable();
DataTable dt1 = new DataTable();
//bind datatable
var rows1_10 = from item in dt1.AsEnumerable()
     select item;
var top1_10 = rows1_10.Take(10);
//do a for-loop and insert into dtMain
DataTable dt2 = new DataTable();
//bind datatable
var rows2_10 = from item in dt2.AsEnumerable()
     select item;
var top2_10 = rows2_10.Take(10);
//do a for-loop and insert into dtMain
0
Rajesh Kumar

Rajesh Kumar

NA 66 0 14y

Hi Purna,
Try to create  two temp datasets with a datatable containing 10 rows. and bind these two dataset to gridviews seperately.
Thanks
Rajesh