protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DropDownList1.DataSource = Business.Listcategory(); DropDownList1.DataTextField = "CategoryName"; DropDownList1.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //getting data for DropDownList1 var catlist = Business.Listcategory(); ItemCategory a = new ItemCategory(); a.CategoryName = "---Select Item Category---"; catlist.Insert(0, a); DropDownList1.DataSource = catlist; DropDownList1.DataTextField = "CategoryName"; DropDownList1.DataBind(); } }