I have a GridView with some BoundFields and two TemplateFields . In these two TemplateFields I dynamically create a UserControls containing a DropDownList and a TextBox that users can modify.
When I try to get control values after PostBack , the values in BoundFields still exist, but my dynamic controls disappear. I can create them again, but it won’t get user values ... How can I get these values before they are lost?
Here are some of my codes:
In the RowDataBound event:
Select Case type Case "BooleanBis" e.Row.Cells(2).Controls.Clear() Dim list1 As BooleanBisList = New BooleanBisList(avant, False) e.Row.Cells(2).Controls.Add(list1) e.Row.Cells(4).Controls.Clear() Dim list2 As BooleanBisList = New BooleanBisList(apres, True) e.Row.Cells(4).Controls.Add(list2) Case "Boolean" e.Row.Cells(2).Controls.Clear() Dim list3 As BooleanList = New BooleanList(avant, False) e.Row.Cells(2).Controls.Add(list3) e.Row.Cells(4).Controls.Clear() Dim list4 As BooleanList = New BooleanList(apres, True) e.Row.Cells(4).Controls.Add(list4) End Select
In my click button event, I am trying to get user control:
Case "String" temp.ChampValeurApres = DirectCast(Tableau1.Rows(i).Cells(selectedColumn).Controls(1), TextBox).Text
but I get an error that it does not exist.
user874854
source share