I have a dropdownlist populated with code directly from the database. But there is a choice point that does not matter at the bottom. How can I bind data from a database exclusively / completely to avoid getting this empty choice in the future?
protected void DropDownList_OnDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
DropDownList ddlName = (DropDownList)e.Row.FindControl("ddlName");
ddlName.DataSource = MyClass.NameList();
ddlName.DataTextField = "Name";
ddlName.DataValueField = "id";
ddlName.DataBind();
}
}
source
share