drop down list checked

Posted by KareemSaad on Stack Overflow See other posts from Stack Overflow or by KareemSaad
Published on 2010-04-19T16:04:17Z Indexed on 2010/04/19 16:23 UTC
Read the original article Hit count: 232

Filed under:
|

I had Drop down list which execute code when specific condition and I tried to check it through selected value but it get error

 protected void DDLProductFamily_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (DDLProductFamily.Items.FindByText("Name").Selected == true)
        using (SqlConnection Con = Connection.GetConnection())
        {
            SqlCommand Com = new SqlCommand("GetListViewByProductCategory", Con);
            Com.CommandType = CommandType.StoredProcedure;
            Com.Parameters.Add(Parameter.NewInt("@ProductCategory_Id", DDLProductFamily.SelectedValue.ToString()));
            SqlDataAdapter DA = new SqlDataAdapter(Com);
            DA.Fill(dt);
            DataList1.DataSource = dt;
            DataList1.DataBind();
        }
        else if (DDLProductFamily.Items.FindByText("ProductFamilly").Selected == true)
        {
            using (SqlConnection Con = Connection.GetConnection())
        {
            SqlCommand Com = new SqlCommand("GetListViewByProductFamily", Con);
            Com.CommandType = CommandType.StoredProcedure;
            Com.Parameters.Add(Parameter.NewInt("@ProductFamily_Id", DDLProductFamily.SelectedValue.ToString()));
            SqlDataAdapter DA = new SqlDataAdapter(Com);
            DA.Fill(dt);
            DataList1.DataSource = dt;
            DataList1.DataBind();
        }
        }
    }

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about c#