In the
Page_Init
event, you have to init your drop down list with data read from the database, like in the next example:
protected void Page_Init(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
try
{
List<Group> centerList = DataContext.Groups.ToList<Group>();
SortedDictionary<string, int> sortedData = new SortedDictionary<string, int>();
_groupDropDownList.DataSource = sortedData;
_groupDropDownList.DataValueField = "value";
_groupDropDownList.DataTextField = "key";
_groupDropDownList.DataBind();
_groupDropDownList.Items.Insert(0, new ListItem("All Groups", "0"));
_groupDropDownList.SelectedIndex = 0;
}
catch (Exception ex)
{
RaGridViewEventLog.LogException(ex);
this.ErrorMessage = "Error in loading the data from the database!";
}
}
}