Solved

Binding a DropDownList to a GridView

Posted on 2009-04-05
7
404 Views
Last Modified: 2012-05-06
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
Comment
Question by:NigelRocks
  • 4
  • 3
7 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24072589
0
 
LVL 1

Author Comment

by:NigelRocks
ID: 24072604
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
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 24072626
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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:NigelRocks
ID: 24072714
I'm assuming I re-query against the DataSource of the GridView.  How do I do that?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24072752
how do you run the data source initially?
0
 
LVL 1

Author Comment

by:NigelRocks
ID: 24072785
I have a dropdownlist bound to a table datasource and a gridview bound to a table source.  I run them by hitting "click".
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 500 total points
ID: 24072820
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

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Footer for each row on Gridview 2 32
Where is this file? 3 25
Easy filter aspnet 2 24
VStudio 2015 WebAPi works fine from local debug not working from published IIS7 1 15
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question