By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,966 Members | 1,488 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,966 IT Pros & Developers. It's quick & easy.

Having "ALL ITEMS" in databound dropdownlist

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.