Solved

Binding a DropDownList to a GridView

Posted on 2009-04-05
7
408 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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