control text in a text box inside a Form view

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
hhamed
2/25/2007 9:00:28 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies
896 Views

Similar Articles

[PageSpeed] 59

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
limno
2/26/2007 12:10:25 AM
Reply: