Click here to Skip to main content
15,909,332 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to call function on this code

DropDownList4.SelectedItem.Text = ?

I have one registration form. I have made cascading dropdownlist in which data of state dropdownlist is loaded on selected index change of Country. sql database is having table Country and State.

I am loading all data(other page, like here it is edit profile) which was submitted during registration on page load event at respective textboxes and dropdownlist. The problem is that Country is loading perfectly on country dropdown but the value of respective state is not loading on state drop down.

code that i am using is as below

C#
protected void loadinternshipdata()
       {
           SqlConnection con = new SqlConnection("Data Source=ja-pc\\sqlexpress;Initial Catalog=Internship;Integrated Security=True;Pooling=False");

           con.Open();
           SqlCommand cmd3 = new SqlCommand("select * from Internship where CompanyID=" + Convert.ToInt16(Session["CompanyID"].ToString()), con);

           SqlDataAdapter daa = new SqlDataAdapter(cmd3);
           DataTable dtt = new DataTable();
           daa.Fill(dtt);
           if (dtt.Rows.Count > 0)
           {

               DropDownList3.SelectedItem.Text = dtt.Rows[0]["Country"].ToString();
              DropDownList4.SelectedItem.Text = dtt.Rows[0]["State"].ToString();
           }
       }
Posted
Updated 1-Apr-14 1:10am
v2
Comments
Sunasara Imdadhusen 1-Apr-14 4:13am    
What do you mean call function? It is not clear at all. can you please provide more detail so other can give proper answer!

1 solution

public void DropDownList_selectionindexchanged()
{
C#
if (DropDownList4.SelectedItem.Text == ?)
{
    yourfunction();
}


}



yourfunction()
{

}
 
Share this answer
 
Comments
Pranav-BiTwiser 1-Apr-14 5:06am    
above code will do...

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