Click here to Skip to main content
13,006,020 members (52,654 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all expert,

I create one dropdownlist in and this dropdownlist will get data from database by using dataset. here is the code from get from datatset.

TEST.Service ats = new TEST.Service();
DataSet dset =TEST.GetCustomerList();
this.tcustomer.DataSource = dset;
this.tcustomer.DataTextField = "name";
this.tcustomer.DataValueField = "code";

For this code, it will display all customers code and name into dropdownlist and the default customer name will be the first one(Customer A).
when i select customer E, the dropdownlist will automatic select to Customer A after i leave my mouse from it.
My question is How can i select any value from dropdownlist and it not select the first values?


Posted 14-Nov-12 14:44pm
Updated 14-Nov-12 15:36pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Where are these codes? They should be in the code as below

   if (! IsPostBack)
      //  first time the page is loaded.
Rahul Rajat Singh 15-Nov-12 1:00am
This seems to be the right solution based on the information provided. +5.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Try this code

ds = BFField.BFActionCombo(CField);
dt = ds.Tables[0];
ddlAction.DataSource = dt;
ddlAction.DataValueField = dt.Columns["Value"].ToString();
ddlAction.DataTextField = dt.Columns["Description"].ToString();
ddlAction.Items.Insert(0, new ListItem("--- Select ---", "0"));

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170628.1 | Last Updated 14 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100