private void InitializeView() { if (!IsPostBack) { if (AgencyList != null && AgencyList.Count() > 0) { BindData(); } else { DisplayMessage("Cannot add to another Agency. The User has been already assigned to all existing Agencies.", true); EndRequest = true; Page.DataBind(); } } }
private void BindAgenciesForUser() { DropDownList AgenciesDLLObj = (DropDownList)formView.FindControl("ddlAgencies"); AgenciesDLLObj.DataSource = AgencyList; AgenciesDLLObj.DataTextField = "Value"; AgenciesDLLObj.DataValueField = "Key"; AgenciesDLLObj.DataBind(); if (AgencyList == null || AgencyList.Count() == 0) { AgenciesDLLObj.Items.Add(new ListItem("No agencies available", "0")); } else { AgenciesDLLObj.Items.Insert(0, new ListItem("-- Select agency --", "0")); } }