Get Text From DropDownList

D

David C

I have a dropDownList control that I am getting the selected value and text
from. The DropDownList is bound to a lookup table with an int column and a
varchar column. The int column is bound to the value and the varchar is
bound to the text. However, when I try to retrieve them in code I am
getting the same value (number) for both. Below is my code. Can someone
tell me what I am doing wrong? Thanks.

David

Dim varLinkIDNew
varLinkIDNew = vwHistory.FindControl("ddlTransLinkIDNew")


strSQLx = "INSERT INTO dbo.CompanyMerger" & _
" (CompanyID, LinkIDInto, CompanyName, MergerDate)" & _
" VALUES (" & txtcoid.Text & ", " & varLinkIDNew.SelectedValue &
", '" & _
varLinkIDNew.Text & "', '" & strTransDate & "')"
 
G

Gaurav Vaish \(a.k.a. MasterGaurav\)

Hi David,
" (CompanyID, LinkIDInto, CompanyName, MergerDate)" & _
" VALUES (" & txtcoid.Text & ", " & varLinkIDNew.SelectedValue &
", '" & _
varLinkIDNew.Text & "', '" & strTransDate & "')"

Use:

varLinkIDNew.SelectedItem.Text
:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top