Click here to Skip to main content
15,895,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using datalist control an asp.net using C# and sqlserver 2008.I have a dropdown in datalist and need to display it's current value from database on page load.

i have tried this so far

C#
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
       {



if (e.Item.ItemType == ListItemType.Item)
{ DropDownList ddlshowit = (DropDownList)e.Item.FindControl("DropDownList4");
ddlshowit.DataSource = ds;
ddlshowit.DataTextField = "showit";
ddlshowit.DataValueField = "showit";
ddlshowit.DataBind();
}
}

I also used

SelectedValue='<%#Eval("showit")%>' but it also did'nt work. Please Help
Posted

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