ToBe

ToBe

  • NA
  • 164
  • 94.4k

Related DropDownlists

May 26 2013 4:45 AM
Hi 

I have 3 related Dropdownlist in me Edit Form 

I'm using the code  below to bind the Dropdownlist but it will retrive the full list without the selected value saved  and if i'm making a selected statment it will just retrive the selected value.

the dropdownlist is linked to other one so if the Category been saved as "Art" the Subject should retrive the saved Item the user selected earlier with the rest items for update purpose .

private void BindDrp_CAT()
        {


           using (SqlConnection con = new SqlConnection(myconn))


            if (!IsPostBack)
            {


                SqlCommand com = new SqlCommand("select distinct Cat_name from tblCategory order by Cat_name ", con);


                 SqlDataReader dr;
                con.Open();


                Drp_CAT.Items.Clear();


                dr = com.ExecuteReader();
                while (dr.Read())
                {
                    Drp_CAT.Items.Add(new ListItem(dr[0].ToString()));
                   
                }
                con.Close();
               


            }
       
       
        }



Answers (5)