ASP 2.0 Question

  • Thread starter Thread starter Lou Civitella
  • Start date Start date
L

Lou Civitella

I have a asp page that has 3 list boxes on it and one combo box. When the
user selects an item from each of the list boxes it automatically shows the
data in a Grid View. I can select different items from each list box and the
grid view will be filtered. I want to be able to have the combo box be used
in the filtering of the grid view but I have a problem with it. The combo
box list different types plus listed at the top it lists 'ALL'

I want to be able to change the data source of the grid view based upon what
the user selects in the combo box. If they select 'All' I want them to see
all the items but if they select a specific item in the list I want the grid
view to only show those values that match.

How do I do something like an item statement to change the data source of
the grid view based upon the combo box values?

Thanks,
Lou

Also in the grid view how can I format a curreny column to only show 2
decimal places?
 
I would:

Create a Strongly Typed DataSet to hold the Data.
On the first page load... load the DS and cache it.

The DataSet will have a .Select method. You can filter and sort on this.

When the use selects an item from the ComboBox or SelectBoxes.. you
basically create a WHERE clause.

If the user picks "ALL", then remove that filter.

...

After setting the values in the listboxes and combo box, put a button like
"Search"

On the code behind of the search.... get teh cached copy of the DS.
String manipulate and create your WHERE clause

string whereClause;
if (this.cboBoxEmpID.selectitem.text != "ALL")
{
whereClause = "EmpID = " + this.cboBoxEmpID.selecteditem.value;
}

then do a

myds.Select(whereClause);

rebind the ds to the Grid.

thats the basic premise.

use the Session["somekey"] to cache the DS.
loop over you drop downs to create some sql.

the strongly typed dataset is the quickest way to get multi level
sorting..because of hte magical .Select method.
If you do a .Select(""), you just get back all the row.
 
Back
Top