Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello

I have a problem in Drop Downstairs control please help me

Here are tow Drop Down-list control which one of theme Bind to Province TB anther one is Bind to District TB,

Now in Edit page form I want show the Province Name and District Name of that ID in Drop Down-list which redirected from main page by Query string
the drop downlist display the First ID like 1

Here is my code
public void ReadSchool()
  {
      string strcmd = "select *from School where S_ID=@SIID";
      SqlCommand cmd = new SqlCommand(strcmd, con);

      cmd.Parameters.AddWithValue("@SIID", Request.QueryString["SID"].ToString());
      con.Open();
      SqlDataReader dr = cmd.ExecuteReader();
      while (dr.Read())
      {

          TextNameschool.Text = dr["SName"].ToString();
          TextCode.Text = dr["Code"].ToString();
          DropGrade.SelectedValue = dr["Grade"].ToString();
          Dropgender.SelectedValue = dr["Gender"].ToString();
          DropType.SelectedValue = dr["Type"].ToString();

          DropProvince.SelectedValue = dr["ProvinceID"].ToString();
          DropDistrict.SelectedValue = dr["DistrictID"].ToString();
Posted
Comments
Are you sure that the DropDownLists are loaded before selecting it by value?
venkatesh@India 7-Jun-15 9:16am    
Try to use the dropdown.selectedItem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900