Problem with dropdownlis(beginner)

  • Thread starter Thread starter Eiffla
  • Start date Start date
E

Eiffla

Hi
I have problem :)
//ds is fill data

DropDownList1.DataSource = ds;
DropDownList1.DataTextField = ds.Tables[0].Columns["username"].ToString();

DropDownList1.DataValueField = ds.Tables[0].Columns["pkid"].ToString();

DropDownList1.DataBind();

when I whant DropDownList.SelectItem.text selected item is always first
username ?? why ??

I will by very grateful for any help

thens
 
Because you are rebinding the value on postback, wrap the code below in an

if (!Page.IsPostBack) {
....code here
}

by rebinding all values are being reset

Karl
 
Back
Top