R – How to get value of dynamically added column of datagridview at time of postback

asp.netdynamicgridviewtemplates

I have made a one form with functionality to create grid view dynamically.

I have used concept of "how to create template columns dynamically in a grid view"

Link: https://www.codeproject.com/KB/aspnet/DynamicTemplateColumn.aspx

it's working good.

I am creating control run time set the different property of control and bind it to gridview columns.

For example if I want to add text box column into gridview,
then I create text box, set the different property of text box, and add that template to gridview column.

But the problem is, once page datagrid load with textbox column, I am enter some data in that column.

then click on save button on page. when i clicked on save then after postback I am not able to get data of that text box column.

For Example

1) Load gridview with Text Box Column (Added runtime)

2) Added one row in Datagridview

2) Write data in that column(Text box column)

3) Click Save button (to save data of gridview)

4) Page post back (Here Gridview has no rows!)

It shows row count 0 when page post back!

So How to get value of that text box column?

Best Answer

Be sure to access the page at the correct time. If you access it in the OnInit event, the ViewState will not have been mapped back on your grid.

PageLoad would be appropriate probably.

Related Topic