Hello
I have four Dropdownlist and i want to show data in gridview.
when i select from ddlCategory[Dropdownlist] is not Null and other dropdown are null then i want to show only one category that time else return all the category.
But its showing all the category in if condition..plz help
con.Open();
if (ddlCategory.SelectedValue != "" && ddlSubCategory.SelectedItem.Text == "" && ddlBrand.SelectedItem.Text == "" && ddlItem.SelectedItem.Text == "")
{
SqlCommand cmd = new SqlCommand("select Distinct Category from tblMatCat where Category = @Category ", con);
cmd.Parameters.AddWithValue("@Category", ddlCategory.SelectedItem.Text);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
}
else
{
SqlCommand cmd = new SqlCommand("select Distinct Category from tblMatCat ", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
}
7 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

Ruchi SharavatPosted Aug 31, 2018, 5:16 AM
Jignesh KumarPosted Aug 25, 2018, 4:02 AM
ankit gaurPosted Aug 25, 2018, 1:57 AM
Code AlonePosted Aug 24, 2018, 1:01 PM
Vincent Maverick DuranoPosted Aug 24, 2018, 10:33 AM
Jignesh KumarPosted Aug 24, 2018, 10:27 AM
Jignesh KumarPosted Aug 24, 2018, 3:54 AM