Having "ALL ITEMS" in databound dropdownlist

C

Cirene

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!
 
M

Munna

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
 
C

Cirene

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.

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
 
C

Cirene

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top