public void citynamesbinding() { Code cd = new Code(); DataSet ds = cd.viewcitydata(); if (ds != null && ds.Tables[0].Rows.Count > 0) { DropDownList1.DataTextField = "Name"; DropDownList1.DataValueField = "ID"; DropDownList1.DataSource = ds; DropDownList1.DataBind(); DropDownList1.Items.Insert(0, "Select City"); } }