DropDownList DataBind

shahab

Junior Contributor
Joined
Aug 14, 2003
Messages
206
Location
Iran(Middle East)
I use this code for DropDownList DataBind:
void BindDDL()
{
try
{
string strCon = ConfigurationSettings.AppSettings["ConnStr"];
SqlConnection wg = new SqlConnection(strCon);

SqlDataAdapter dtAdap1 = new
SqlDataAdapter("select Username from tblUserAccounts",wg);


dtAdap1.Fill(dsDDL, "tblUserAccounts");

DropDownList1.DataBind();
}
catch (Exception DDLError)
{
Label8.Text=DDLError.Message.ToString();
}
}
But it does not shows the usernames!
 
No ,What should I write there?
DataBinding:DataBinder.Eval(dsDDL, "Tables[tblUserAccounts].DefaultView.[0].username")
but it shows only the first username not all of them!!
 
Last edited:
Back
Top