Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all expert,

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

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

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?

Thanks

TONY
Posted
Updated 14-Nov-12 15:36pm
v4

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

if (! IsPostBack)
{

   //  first time the page is loaded.

}
 
Share this answer
 
Comments
Rahul Rajat Singh 15-Nov-12 1:00am    
This seems to be the right solution based on the information provided. +5.
Try this code

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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900