U
Unforgiven
I have an ASP.NET page with 14 different text box on it that gets data from
a SQL Server database. Please see the following code.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
SqlDataAdapter1.Fill(DataSet11)
If Not IsPostBack Then
'This works
'TextBox1.DataBind()
'TextBox2.DataBind()
'TextBox3.DataBind()
'TextBox4.DataBind()
'TextBox5.DataBind()
'TextBox6.DataBind()
'TextBox7.DataBind()
'TextBox8.DataBind()
'TextBox9.DataBind()
'TextBox10.DataBind()
'TextBox11.DataBind()
'TextBox12.DataBind()
'TextBox13.DataBind()
'TextBox14.DataBind()
'Why doesn't this work?
Dim c As Control
For Each c In Controls
If TypeOf c Is TextBox Then
c.DataBind()
End If
Next
End If
End Sub
Why does the top portion (that is commented out) work but the part that
loops through the collection does not? Is there something that I have to
reference gloablly? Is there something that I'm missing here?
Thanks,
-U
PS. I'm new to .NET
a SQL Server database. Please see the following code.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
SqlDataAdapter1.Fill(DataSet11)
If Not IsPostBack Then
'This works
'TextBox1.DataBind()
'TextBox2.DataBind()
'TextBox3.DataBind()
'TextBox4.DataBind()
'TextBox5.DataBind()
'TextBox6.DataBind()
'TextBox7.DataBind()
'TextBox8.DataBind()
'TextBox9.DataBind()
'TextBox10.DataBind()
'TextBox11.DataBind()
'TextBox12.DataBind()
'TextBox13.DataBind()
'TextBox14.DataBind()
'Why doesn't this work?
Dim c As Control
For Each c In Controls
If TypeOf c Is TextBox Then
c.DataBind()
End If
Next
End If
End Sub
Why does the top portion (that is commented out) work but the part that
loops through the collection does not? Is there something that I have to
reference gloablly? Is there something that I'm missing here?
Thanks,
-U
PS. I'm new to .NET