Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dropdown value

Status
Not open for further replies.

henslecd

MIS
Apr 21, 2003
259
US
I have a dropdown box...

<asp:DropDownList id=&quot;ddVendor&quot; runat=&quot;server&quot; Width=&quot;226px&quot; DataTextField=&quot;VENDOR&quot; DataValueField=&quot;PK_VENDOR_ID&quot;></asp:DropDownList>

I have this in the button_click event...

Dim vendorID as integer

vendorID = ddVendor.SelectedItem.Value

I thought this would get the PK_VENDOR_ID value.

Can someone point me in the right direction?
 
2 things to check.

1. Is the dropdown object being populated?
2. Are you selecting an item? If you just populate the field, but do not select an item or default to an item, then no item is selected.

To select a default value add this line of code after you bind the data source.
[tt]ddVendor.SelectedIndex = 0[/tt]
This will select the first item in the list. The default is -1 (no selection.)

Jason Meckley
Database Analyst
WITF
 
I am populating from a dataset.

I am trying to get the PK_VENDOR_ID that corresponds to the VENDOR I select so I can write it to the database.
 
post your code, that may help shed light on the situation.

Jason Meckley
Database Analyst
WITF
 
Nevermind.

I just used the old ASP way ...I thought it was different in ASP.NET.

vendorID = Request.Form(&quot;ddVendor&quot;)

Thank you for your time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top