Hi Friend, put you code inside on IsPostBack ==false like below code and put the DataTextField and DataValueField properly like this. this code should be in Page_Load events. if (!IsPostBack) { SqlConnection con = new SqlConnection("your connection string here"); SqlDataAdapter da = new SqlDataAdapter("Select StateId,StateName From StateMaster", con); con.Open(); DataSet ds = new DataSet(); da.Fill(ds); DropDownList1.DataSource = ds; DropDownList1.DataTextField = "StateName"; // your dispaly field in dropdownlist DropDownList1.DataValueField = "StateId"; // your value field which you will stare in database DropDownList1.DataBind(); con.Close(); }
Anil Pathak worked on technologies like C#, VB.net, ASP.net, Web Service, WCF, WPF, Silver Light, MVC 3.0, Jquery, Sql Server.