I want to get text from a querystring into a text box that is prt of a form view. I have tried writing code in the page load that changes the text value inside that text box but i get the error that the texbox name is not in the current context. My question is how to call a textbox (or any other control) inside a form view?
![]() |
0 |
![]() |
You can use the FormView's OnDataBound event to access the textbox on your formview:
OnDataBound="FormView1_OnDataBound"
Protected Sub FormView1_OnDataBound(ByVal sender As Object, ByVal e As EventArgs)
If FormView1.CurrentMode = DetailsViewMode.Insert Or FormView1.CurrentMode = DetailsViewMode.Edit Then
Dim TextBox1 As TextBox
TextBox = CType((FormView1.FindControl("yourTextBox")), TextBox)
If Not TextBox1 Is Nothing Then
TextBox1.Text = Request.QueryString("myState").ToString()
End If
End If
End Sub YouTextBox is your TextBox's name in both Insert and Edit ItemTemplate.
Limno
![]() |
0 |
![]() |