How to find the Dynamically added gridview footer control
- by harold-sota
I have add controls to my gridview footer,
here is the code
SGridView.ShowFooter = True
For i As Integer = 0 To ctrList.Count
Dim ctr As Control = CType(ctrList.Item(i), Control)
SGridView.FooterRow.Cells(i + 1).Controls.Add(ctr)
Next
the ctrList contain Controls textBox, checkbox dropdowlist ect.
there is all ok
but when i wont to get the text or value or checked value of controls i cant cast the controls in rowcommand event
Here is the code:
Protected Sub SGridView_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles SGridView.RowCommand
If e.CommandName = "Add" Then
Dim ctrList As ControlCollection = SGridView.FooterRow.Controls
For Each ctr As Control In ctrList
If TypeOf ctr Is TextBox Then
Dim name As TextBox = CType(ctr, TextBox)
Dim val As String = name.Text
End If
Next
End If
this excample is for the textBox control.
Any idea?