I have a dropdown control into a page and a gridview, both are associated to
two SqlDataSource controls, one of them is used to fill the DropDownControl ,
that is meant to be a filter over the query of the other SqlDatasource
associated to the grid. This works fine, whenever I choose an item in the
dropdown combo, I get a filtered grid.
I did this using the declarative syntax, without writing any code. ok, now I
want to put another item at the top of the combobox, to get an unfiltered
list, so the question is:
is there a fast way of doing this ? I could think about handling the
SelectedIndexCh anged event of the combo to change the datasource of the grid
or the query used, but i would like to know if there was a more elegant and
faster way of doing this, with a declarative syntax, by using some unknown
property of the grid or datasource controls, or changing the select query.
thanks 2 1529
Here's how I did mine....
On the dropdownlists databound event, use this:
DropDownList1.I tems.Insert(0, "All Results...")
(or whatever you want the text to be. 0 is the zero based item index of the
control.)
Then on the ddl's selectedindexch anged event, check the value
IF ddl1.SelectedVa lue = "All Results..." THEN
SqlDataSource1. SelectCommand = "select * from table order by col1"
SqlDataSource1. DataBind()
ELSE
SqlDataSource1. SelectCommand = "select * from table where col2 = '" &
ddl1.selectedva lue & "' order by col1"
END IF
Also make sure autopostback is enabled for the ddl control.
"Spartaco" wrote: I have a dropdown control into a page and a gridview, both are associated to two SqlDataSource controls, one of them is used to fill the DropDownControl , that is meant to be a filter over the query of the other SqlDatasource associated to the grid. This works fine, whenever I choose an item in the dropdown combo, I get a filtered grid.
I did this using the declarative syntax, without writing any code. ok, now I want to put another item at the top of the combobox, to get an unfiltered list, so the question is:
is there a fast way of doing this ? I could think about handling the SelectedIndexCh anged event of the combo to change the datasource of the grid or the query used, but i would like to know if there was a more elegant and faster way of doing this, with a declarative syntax, by using some unknown property of the grid or datasource controls, or changing the select query.
thanks
sorry forgot the datasource databind() function in ELSE
"pickedanam e" wrote: Here's how I did mine.... On the dropdownlists databound event, use this: DropDownList1.I tems.Insert(0, "All Results...") (or whatever you want the text to be. 0 is the zero based item index of the control.) Then on the ddl's selectedindexch anged event, check the value IF ddl1.SelectedVa lue = "All Results..." THEN SqlDataSource1. SelectCommand = "select * from table order by col1" SqlDataSource1. DataBind() ELSE SqlDataSource1. SelectCommand = "select * from table where col2 = '" & ddl1.selectedva lue & "' order by col1" END IF
Also make sure autopostback is enabled for the ddl control.
"Spartaco" wrote:
I have a dropdown control into a page and a gridview, both are associated to two SqlDataSource controls, one of them is used to fill the DropDownControl , that is meant to be a filter over the query of the other SqlDatasource associated to the grid. This works fine, whenever I choose an item in the dropdown combo, I get a filtered grid.
I did this using the declarative syntax, without writing any code. ok, now I want to put another item at the top of the combobox, to get an unfiltered list, so the question is:
is there a fast way of doing this ? I could think about handling the SelectedIndexCh anged event of the combo to change the datasource of the grid or the query used, but i would like to know if there was a more elegant and faster way of doing this, with a declarative syntax, by using some unknown property of the grid or datasource controls, or changing the select query.
thanks This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mike O. |
last post by:
MS Access 2003 "filter by form" has drop down lists that allow the
user to select values for each field to filter by. However, once some
values are selected,the remaining dropdown lists remain the same and
aren't progressively filtered to reflect the selections already made
in other fields. This can be very tedious when filtering a large
datasheet. Unlike Access, the MS Excel autofilter has automatic
progressive filtering of value...
|
by: bbdata |
last post by:
ok i have a problem here and not much time to play round.
have a form bound to a table. one of the combos is bound to a field
Agents. i have active and retired agents. thing is, i want to be able
to retrieve all agents from the table, but to see only active in
dropdown list of the combo, to asure accurate data entry. if i filter
the agents table for a rowsource to get back only active in the
dropdown, i cant retreive names of the rest when...
|
by: origin197511 |
last post by:
Hello all...
I'm having an issue with MSAccess 2000. I have a Form that holds
records of my cartridge loads for a rifle and a subform that lists all
groups that have been fired with that load. They are linked by the
load_id field and when I just browse through the loads everything shows
up correctly. Each recorded group is displayed on a line of the
datasheet subform. However, when I filter the form for say my
"Selected" flag...
|
by: GSteven |
last post by:
(as formerly posted to microsoft.public.access.forms with no result)
I've created a continuous form which is based on a straightforward table
(ex - customers - 100 records). On the form there is a checkbox with a
control source named "MARK" (boolean) from customer table. I can check and
uncheck individual records fine. Then I created 2 command buttons named
"Select All" and "Deselect All". The Onclick property of these buttons runs
code...
|
by: DXJas |
last post by:
I have a form that calls a stored procedure to perform updates to a table in
sqlserver.
When I have a dropdown with a list item value of nothing, the formview
control passes up the wrong value to the stored procedure. In some cases
this will be the primary key for my record and in a different dropdown on the
same page I may get the "*" symbol. I'm not sure what the problem is though.
NOte: I did have an issue setting up the formview...
| |
by: jung_h_park |
last post by:
From: jung_h_park@yahoo.com
Newsgroups: microsoft.public.dotnet.framework.aspnet
Subject: Dropdown List not retaining its SelectedValue
Date: Mon, 26 Jun 2006 21:02:57 -0700
Hello,
My dropdown list control does not retain its SelectedValue. Unless I
read the SelectedValue right after the control has been loaded,
populated, and assigned with its original value (and of course that is
|
by: Fretners |
last post by:
I have a form that displays the contents of a table. I want to be able to apply filters though the form and then base an insert query on the filtered data to create a new row to match each row in the filtered data.
Is there a way to get the filtered data from the Id field / control from this form?
Thanks
|
by: SF |
last post by:
Hi,
I am new to ASP.NET. I started my first testing ASP.NET by having a ASP page
consist of a drop-down control and 1 datagrid bound to Access database. The
dropdown control works very well except the datgrid becuase I want to limit
the datgrid to display only information selected in the dropdown control.
For this purpose I have create a dataset having a query that would serve as
source to datagrid. I am unable to specify the parameter...
|
by: Ironr4ge |
last post by:
Hi everyone,
I am trying to open the form "Languages" with a diffrent record
source
to the "Contacts" form where I conducted the search or filter... .
I was wondering whether there was a vba code to select
ONLY ALL FILTERED records of my first form or the "Contacts"
and open this filtered set of records in my "Languages" form. I have a
key field on both tables named id_individual.
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |