Link to home
Start Free TrialLog in
Avatar of Wildone63
Wildone63

asked on

Finding controls in Formview Insert Template

I am using VS 2008 VB.net and SQL 2005.

I have a formview on an aspx page and I have completed the Insert Template.

On the insert template I have a drop-down list for the Customer# and the Customer Address fields below that. My goal is that when the user selects the Customer# in the dropdown list the address fields are filled in.

My Problem is that I can not figure out how to address the textbox fields in the formview Insert template.

This is what I am trying....
    Protected Sub DropDownList2_SelectedIndexChanged1(ByVal sender As Object, ByVal e As EventArgs)
        Dim addr2 = CType(sender, DropDownList).SelectedValue

        Dim connectionString As String = "Data Source=bodb1;Initial Catalog=Depot;Persist Security Info=True;User ID=webuser;Password=password"
        Dim dbcon As New SqlConnection(connectionString)
        dbcon.Open()
        Dim dbcmd As New SqlCommand
        dbcmd.CommandText = "select address from les01 where cshipno like 'addr2'"
        dbcmd.Connection = dbcon

        CType(FormView1.FindControl("AddressTextBox"), TextBox) = dbcmd.ExecuteScalar

        dbcmd.Dispose()
        dbcon.Dispose()
   
    End Sub


This Line
 CType(FormView1.FindControl("AddressTextBox"), TextBox) = dbcmd.ExecuteScalar

Gives the error "expression is a value and therefore cannot be the target of an assignment."

ASKER CERTIFIED SOLUTION
Avatar of Saqib Khan
Saqib Khan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Wildone63
Wildone63

ASKER

OMG. I can't believe I missed that.

THANK YOU!