Solved

Finding controls in Formview Insert Template

Posted on 2010-11-10
2
573 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

21 Experts available now in Live!

Get 1:1 Help Now