How to find the Dynamically added gridview footer control
Posted
by harold-sota
on Stack Overflow
See other posts from Stack Overflow
or by harold-sota
Published on 2010-05-11T14:48:31Z
Indexed on
2010/05/11
16:44 UTC
Read the original article
Hit count: 241
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?
© Stack Overflow or respective owner