Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Contributor
4181 Points
1041 Posts
Feb 21, 2012 07:05 PM|LINK
you have to define DataTextField and DataValueField as well. Try using SqlDataAdpter :
DataSet lvDS = new DataSet(); SqlDataAdapter myda = new SqlDataAdapter("select [Client Name] from Accounts ", conn); myda.Fill(lvDS); ProvTab_Client_DropDown.DataSource = lvDS; ProvTab_Client_DropDown.DataTextField = "ClientName"; ProvTab_Client_DropDown.DataValueField = "ClientId"; ProvTab_Client_DropDown.DataBind();
more here:
http://www.progtalk.com/viewarticle.aspx?articleid=194
rajsedhain
Contributor
4181 Points
1041 Posts
Re: Define DropDownList DataSource in Codebehind
Feb 21, 2012 07:05 PM|LINK
you have to define DataTextField and DataValueField as well. Try using SqlDataAdpter :
DataSet lvDS = new DataSet(); SqlDataAdapter myda = new SqlDataAdapter("select [Client Name] from Accounts ", conn); myda.Fill(lvDS); ProvTab_Client_DropDown.DataSource = lvDS; ProvTab_Client_DropDown.DataTextField = "ClientName"; ProvTab_Client_DropDown.DataValueField = "ClientId"; ProvTab_Client_DropDown.DataBind();more here:
http://www.progtalk.com/viewarticle.aspx?articleid=194
Raj Sedhain