Get Text From DropDownList

  • Thread starter Thread starter David C
  • Start date Start date
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 & "')"
 
Hi David,
" (CompanyID, LinkIDInto, CompanyName, MergerDate)" & _
" VALUES (" & txtcoid.Text & ", " & varLinkIDNew.SelectedValue &
", '" & _
varLinkIDNew.Text & "', '" & strTransDate & "')"

Use:

varLinkIDNew.SelectedItem.Text
:)
 
Back
Top