• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 432
  • Last Modified:

Binding a DropDownList to a GridView

Experts,

I have a grid view that's tied to a database table.  One of the fields is Product_Category.  I want to select a value for that field from a DropDownList and filter the grid accordingly.  How do I do that?
0
NigelRocks
Asked:
NigelRocks
  • 4
  • 3
2 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
0
 
NigelRocksAuthor Commented:
That's not quite what I'm looking for.  I want to use a DropDownlist OUTSIDE the grid to filter the contents of the grid.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
ok, I see.

you put the dropdownlist, and put the usual code to fill this list from the data source (dataset/datareader) as you need on the first page_load...

ensure the dropdown is "autopostback", and on the selection change event, you will have to run the code to re-query or only re-bind the data grid. the choice depends on how much data you have if unfiltered, and how much time the query for unfiltered/filtered takes.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
NigelRocksAuthor Commented:
I'm assuming I re-query against the DataSource of the GridView.  How do I do that?
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
how do you run the data source initially?
0
 
NigelRocksAuthor Commented:
I have a dropdownlist bound to a table datasource and a gridview bound to a table source.  I run them by hitting "click".
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
can you show the relevant code that you use to query?
in there, you have to use the dropdown's selecteditem property (if != null), to use for example the value, to build the query...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now