private void BindAllProductId() { String cs = ConfigurationManager.ConnectionStrings["MyDatabaseConnectionString1"].ConnectionString; using (SqlConnection con = new SqlConnection(cs)) { SqlCommand cmd = new SqlCommand("select * from ProductTable ", con); con.Open(); SqlDataAdapter sda = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); sda.Fill(dt); //Response.Write(dt1.Rows.Count); if (dt.Rows.Count != 0) { ProductDropDownId.DataSource = dt; ProductDropDownId.DataTextField = "ProductName"; ProductDropDownId.DataValueField = "ProductId"; ProductDropDownId.DataBind(); ProductDropDownId.Items.Insert(0, new ListItem("-Select-", "0")); } } }