Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Finding controls in Formview Insert Template

Posted on 2010-11-10
2
Medium Priority
?
588 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
[X]
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
2 Comments
 
LVL 23

Accepted Solution

by:
Saqib Khan earned 2000 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

In this article I will describe the Copy Database Wizard 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.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

660 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