[2005] Problems with Gridview and Postback
hello everyone!
this is my first post :D
Inside the gridview (see the pic), there are two type of rows
1.- green -> rows obtained by db
2.- red -> rows obtained by rowdatabound event
http://img233.imageshack.us/img233/3528/lalaqg4.jpg
The problem happen when I click the continuar button... I want to obtain the values in the checkbox and textbox fields, but i can't. Apparently the postback event, not triggers the rowdatabound event (in fact there only show two first green marked rows, just in the position there begins rowdatabound event)
Somebody can help me??
thx for the help!!!!
(sorry for my english!)
Re: [2005] Problems with Gridview and Postback
Has EnableViewState been set to true for the GridView? What might be happening (cannot be sure without looking at code) is that you are not rebinding on postback and so the dynamically created rows are being lost somehow. However, if they are dynamically created, they should be recreated in the Init event before each page load, so that when the button click event (continuar) is finally raised, all the control values are available to you.
Re: [2005] Problems with Gridview and Postback
Thank's for your reply...
Has EnableViewState been set to true for the GridView? -> Yes
I'll have a solution, I call the checkbox and textbox fields with:
HTML Code:
Dim Keys() As String
Dim FormElements As NameValueCollection
Dim Counter1 As Integer
FormElements = Request.Form
Keys = FormElements.AllKeys
For Counter1 = 0 To Keys.GetUpperBound(0)
If Keys(Counter1).IndexOf("check") <> -1 Then
'find a checkbox
End If
If Keys(Counter1).IndexOf("textbox") <> -1 Then
'find a textbox
End If
Next
thanks!!
Re: [2005] Problems with Gridview and Postback
That'd be another way to do it I suppose, but if you keep working with dynamic controls, you'll need to keep the recreation of controls in mind as it can be cumbersome to have to do this 'manually' each time.