Solved

Finding controls in Formview Insert Template

Posted on 2010-11-10
2
574 Views
Last Modified: 2012-08-14
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."

0
Comment
Question by:Wildone63
2 Comments
 
LVL 23

Accepted Solution

by:
adilkhan earned 500 total points
ID: 34107761
try

CType(FormView1.FindControl("AddressTextBox"), TextBox).Text = dbcmd.ExecuteScalar
0
 
LVL 1

Author Closing Comment

by:Wildone63
ID: 34107982
OMG. I can't believe I missed that.

THANK YOU!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now