Hey guys, I'm doing a project for university and i have hit a wall. I have a gridview that is connected to a database as shown below:

http://i40.tinypic.com/fys9i.jpg
(menu is incomplete)

I want a drop down box that is populated with the type of food such as (pizzas, burgers etc etc). When the user selects one of the items within the drop down box, how would i filter the gridview to only show the selected type of food? EG
If i was to select Pizzas i would only want the pizzas to be shown..

How would i go about doing this?
Thanks

Assuming you are using an SQLDataSource to bind the gridview, you can add a control parameter linked to your dropdown like so

<SelectParameters>
   <asp:ControlParameter Name="TypeFilter" ControlID="DropDownList1" PropertyName="SelectedValue" />
</SelectParameters>

Your select query must then include the parameter in the where clause, something like

WHERE Type = @TypeFilter

You can set the DropDownList to AutoPostBack="true" so that the grid will refresh whenever the selection changes.

That's essentially all you need to do.

Cheers mate! got it to work :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.