Click here to Skip to main content
15,878,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have one list box when i will select item from list box that time all subitems should be disply from database i have tried following code its working only for some items,its not working for all items.plz help me?


C#
protected void lbcategory_SelectedIndexChanged(object sender, EventArgs e)
    {
        Panelconstruction.Visible = false;
        SqlConnection sqlCon = new SqlConnection();
        sqlCon.ConnectionString = "Data Source=PC-13\\SQLEXPRESS;Initial Catalog=DbPlacementCoordinator;Integrated Security=True";
        sqlCon.Open();
        string str = lbcategory.SelectedItem.Value;
        string query = "Select Industry_ID from Industry_Category where Industry_Name=@str;";
        SqlCommand cmd3 = new SqlCommand(query, sqlCon);
        cmd3.Parameters.AddWithValue("str", str);
        int b = Convert.ToInt16(cmd3.ExecuteScalar());
        string jobcat = "Select Job_Name from Job_Category where Industry_ID=@b;";
        SqlCommand cmd4 = new SqlCommand(jobcat, sqlCon);
        cmd4.Parameters.AddWithValue("b", b);
        SqlDataReader reader = cmd4.ExecuteReader();
        inbox.DataSource = reader;
        inbox.DataBind();

        Panelconstruction.Visible = true;

       }
Posted
Updated 13-Jun-12 23:39pm
v2
Comments
Sandeep Mewara 14-Jun-12 12:30pm    
can you elaborate more on this part: "its working only for some items,its not working for all items"?
Until we don't know what exactly is happening how will we suggest or comment anything?

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