Author: aspbie | Posted on: 11/7/2009 11:10:25 AM | Views : 448

I am trying to add Cities to my state dropdownlist dynamically below, then set that drop down to autopostback = true and call the selected index change event below, but it's not printing me the zip code. It keeps getting the first index 0 item.



string sConn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString(); SqlConnection conn = new SqlConnection(sConn); string sQry = "SELECT DISTINCT City FROM ZipCodes WHERE state = @ddlState"; SqlCommand cmd = new SqlCommand(sQry, conn); conn.Open(); //cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ddlState", "CA"); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { ddlTest.Items.Add(new Li ...

Go to the complete details ...