Solved

Binding a DropDownList to a GridView

Posted on 2009-04-05
7
393 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 142

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 142

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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 142

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 142

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now