Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Finding controls in Formview Insert Template

Posted on 2010-11-10
2
582 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:
Saqib Khan 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

808 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