Fiil Ajax Combobox,Dropdown List
This method is for Filling Ajax DropdownList Control.you just need to pass dropdown list id,sql query and,initial text if you want any.you can put this method in class file and can use anywhere at any page in whole solutions.
This method is for Filling Ajax DropdownList Control.you just need to pass dropdown list id,sql query and,initial text if you want any.you can put this method in class file and can use anywhere at any page in whole solutions.initial Text Will be the text that appears at 0 index if any dropdownList or Combobox.
public void AjaxCombo(AjaxControlToolkit.ComboBox DDL, string SqlQuery, string InitialText)
{
DataTable DtReason = new DataTable();
DataView DvReason = new DataView();
DtReason = dt(SqlQuery);
if (InitialText.Trim().Length > 0)
{
DataRow Dr;
Dr = DtReason.NewRow();
Dr[0] = 0;
Dr[0] = InitialText;
DtReason.Rows.Add(Dr);
}
DvReason = DtReason.DefaultView;
DvReason.Sort = DtReason.Columns[0].Caption.ToString() + " Asc";
DDL.DataSource = DvReason;
DDL.DataValueField = DtReason.Columns[0].Caption;
DDL.DataTextField = DtReason.Columns[0].Caption;
DDL.DataBind();
}