Click here to Skip to main content
12,450,937 members (51,123 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
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.

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 14-Nov-12 14:44pm
Updated 14-Nov-12 15:36pm
v4
Rate this: bad
 
good
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.

}
  Permalink  
Comments
Rahul Rajat Singh 15-Nov-12 1:00am
   
This seems to be the right solution based on the information provided. +5.
Rate this: bad
 
good
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.DataBind();
ddlAction.Items.Insert(0, new ListItem("--- Select ---", "0"));
  Permalink  

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.160826.1 | Last Updated 14 Nov 2012
Copyright © CodeProject, 1999-2016
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