473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Having "ALL ITEMS" in databound dropdownlist

I seem to remember seeing a solution where a databound dropdownlist (used as
a FILTER for a gridview) had the 1st item as "ALL ITEMS". It used a query
with a UNION. But I can't find the example.

It used no code I believe.

Anyone have this solution handy?

Thanks!
Jun 27 '08 #1
5 1863
On Jun 7, 1:53*am, "Cirene" <cir...@nowhere.comwrote:
I seem to remember seeing a solution where a databound dropdownlist (used as
a FILTER for a gridview) had the 1st item as "ALL ITEMS". *It used a query
with a UNION. *But I can't find the example.

It used no code I believe.

Anyone have this solution handy?

Thanks!
Hi

While Configure the data source if you want to set the where clause ,
there is a option that takes param directly from a control

select configure datasource of your datasource...

and then click next to go to the configure select statement...

you will find a button called "where" in the wizard...

click on that... will lunch add new where wizard...

there you can specify column and operator and source from the param ..

there in source drop down you will find a value called from
"control"...

select that and specify the value and default value...

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
Jun 27 '08 #2
The dropdownlist is to filter the @AttachmentEntityId parameter in the
SELECT statement for my grid. Here's the dropdownlist....
<asp:DropDownList ID="ddlStations" runat="server"
DataSourceID="sdsStations"
DataTextField="AttachmentEntityName"
DataValueField="AttachmentEntityId"
Width="143px" AutoPostBack="True"
AppendDataBoundItems="True">
<asp:ListItem Selected="True" Value="%">ALL
STATIONS</asp:ListItem>
</asp:DropDownList>

Here's the SELECT statement for my grid...

SelectCommand="SELECT Appointments.AppointmentId, Appointments.CompanyId,
Appointments.AppointmentName, Appointments.StartDateTime,
Appointments.EndDateTime, Appointments.RecurranceStorage,
Appointments.RecurranceParentKey, Appointments.CreatedByCompanyUserId,
Appointments.CreateDateTime, Appointments.Comments,
AppointmentAttachments.AttachmentEntityId FROM Appointments INNER JOIN
AppointmentAttachments ON Appointments.AppointmentId =
AppointmentAttachments.AppointmentId WHERE (Appointments.CompanyId =
@CompanyId) AND (AppointmentAttachments.AttachmentEntityId =
@AttachmentEntityId)"

<SelectParameters>
<asp:ControlParameter ControlID="ddlCompany" Name="CompanyId"
PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="ddlStations"
Name="AttachmentEntityId"
PropertyName="SelectedValue" />
</SelectParameters>

Again, the error is...
Conversion failed when converting the nvarchar value '%' to data type int.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Conversion failed
when converting the nvarchar value '%' to data type int.

Any ideas? Thanks.

"Munna" <mu******@gmail.comwrote in message
news:67**********************************@h1g2000p rh.googlegroups.com...
On Jun 7, 1:53 am, "Cirene" <cir...@nowhere.comwrote:
I seem to remember seeing a solution where a databound dropdownlist (used
as
a FILTER for a gridview) had the 1st item as "ALL ITEMS". It used a query
with a UNION. But I can't find the example.

It used no code I believe.

Anyone have this solution handy?

Thanks!
Hi

While Configure the data source if you want to set the where clause ,
there is a option that takes param directly from a control

select configure datasource of your datasource...

and then click next to go to the configure select statement...

you will find a button called "where" in the wizard...

click on that... will lunch add new where wizard...

there you can specify column and operator and source from the param ..

there in source drop down you will find a value called from
"control"...

select that and specify the value and default value...

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
Jun 27 '08 #3
Hi

in where clause try replace "=" with "like" operator...

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
Jun 27 '08 #4
awesome - thanks!!!

"Munna" <mu******@gmail.comwrote in message
news:c6**********************************@y22g2000 prd.googlegroups.com...
Hi

in where clause try replace "=" with "like" operator...

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com

Jun 27 '08 #5
Actually I thought LIKE would work...

SELECT Appointments.AppointmentId, Appointments.CompanyId,
Appointments.AppointmentName, Appointments.StartDateTime,
Appointments.EndDateTime,
Appointments.RecurranceStorage,
Appointments.RecurranceParentKey, Appointments.CreatedByCompanyUserId,
Appointments.CreateDateTime,
Appointments.Comments,
AppointmentAttachments.AttachmentEntityId
FROM Appointments INNER JOIN
AppointmentAttachments ON Appointments.AppointmentId =
AppointmentAttachments.AppointmentId
WHERE (Appointments.CompanyId = @CompanyId) AND
(AppointmentAttachments.AttachmentEntityId LIKE @AttachmentEntityId)

But @AttachmentEntityId is still having trouble when a % is sent because
it's not an integer. Though if I type 'LIKE %' in directly to the query it
works fine. Any ideas why? Thanks!

"Munna" <mu******@gmail.comwrote in message
news:c6**********************************@y22g2000 prd.googlegroups.com...
Hi

in where clause try replace "=" with "like" operator...

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com

Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: tobhamlet | last post by:
If one is using a query as a Row Source on a Form, is there a way to set up a blank space, or to insert the word "ALL" in a combo box that represents ALL combo box row items. The scenario is as...
5
by: ad | last post by:
When I study the Portal Starter Kit (http://www.asp.net/Default.aspx?tabindex=8&tabid=47) There is a line in DesktopPortalBanner.ascx.cs PortalSettings portalSettings = (PortalSettings)...
2
by: JohnB | last post by:
hi I am using System.Web.Mail.MailMessage to send email. Is there any way to keep the email to "Sent Items" Folder?? I use Microsoft Outlook as my email tool. Thanks
0
by: VB Newbie | last post by:
I am creating a user control containing a combobox using VB.NET(2003) I want to add 2 public properties "DataSource" and "Items" like the "System.Windows.Forms.ComboBox" here is my code, but it...
5
by: VB Newbie | last post by:
I am creating a user control containing a combobox using VB.NET(2003) I want to add 2 public properties "DataSource" and "Items" like the "System.Windows.Forms.ComboBox" here is my code, but it...
0
by: David Veeneman | last post by:
Is there any way to modify what gets inserted when the "Insert standard items" is selected on a tool strip? Right now I have a form with my standard menu setup saved as a template, but I'd like...
3
by: Cirene | last post by:
I have a databound dropdownlist. It is acting as a "filter" for a gridview. I wanted to add "ALL" to the first item on the list. Question: In the SQLDataSource (that the ddl is bound to) how do...
3
by: kimiraikkonen | last post by:
Hi, I want to display ALL the items (includes unselected items) of listbox control. How can i code this? Should i use "for each" or other? For example: Assume you have a listbox with 3 items...
2
by: COHENMARVIN | last post by:
I have a listbox of cities. The listbox is bound to a database table. But I want to add the option - "all cities" to the listbox. How do I do that? Thanks, Marvin
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.