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_SelectedInde xChanged1( ByVal sender As Object, ByVal e As EventArgs)
Dim addr2 = CType(sender, DropDownList).SelectedValu e
Dim connectionString As String = "Data Source=bodb1;Initial Catalog=Depot;Persist Security Info=True;User ID=webuser;Password=passwo rd"
Dim dbcon As New SqlConnection(connectionSt ring)
dbcon.Open()
Dim dbcmd As New SqlCommand
dbcmd.CommandText = "select address from les01 where cshipno like 'addr2'"
dbcmd.Connection = dbcon
CType(FormView1.FindContro l("Address TextBox"), TextBox) = dbcmd.ExecuteScalar
dbcmd.Dispose()
dbcon.Dispose()
End Sub
This Line
CType(FormView1.FindContro l("Address TextBox"), TextBox) = dbcmd.ExecuteScalar
Gives the error "expression is a value and therefore cannot be the target of an assignment."
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_SelectedInde
Dim addr2 = CType(sender, DropDownList).SelectedValu
Dim connectionString As String = "Data Source=bodb1;Initial Catalog=Depot;Persist Security Info=True;User ID=webuser;Password=passwo
Dim dbcon As New SqlConnection(connectionSt
dbcon.Open()
Dim dbcmd As New SqlCommand
dbcmd.CommandText = "select address from les01 where cshipno like 'addr2'"
dbcmd.Connection = dbcon
CType(FormView1.FindContro
dbcmd.Dispose()
dbcon.Dispose()
End Sub
This Line
CType(FormView1.FindContro
Gives the error "expression is a value and therefore cannot be the target of an assignment."
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
THANK YOU!