Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Having "ALL ITEMS" in databound dropdownlist

Reply
Thread Tools

Having "ALL ITEMS" in databound dropdownlist

 
 
Cirene
Guest
Posts: n/a
 
      06-06-2008
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!


 
Reply With Quote
 
 
 
 
Munna
Guest
Posts: n/a
 
      06-07-2008
On Jun 7, 1:53*am, "Cirene" <(E-Mail Removed)> wrote:
> 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
 
Reply With Quote
 
 
 
 
Cirene
Guest
Posts: n/a
 
      06-08-2008
The dropdownlist is to filter the @AttachmentEntityId parameter in the
SELECT statement for my grid. Here's the dropdownlist....
<aspropDownList 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>
</aspropDownList>

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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
On Jun 7, 1:53 am, "Cirene" <(E-Mail Removed)> wrote:
> 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


 
Reply With Quote
 
Munna
Guest
Posts: n/a
 
      06-08-2008
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
 
Reply With Quote
 
Cirene
Guest
Posts: n/a
 
      06-08-2008
awesome - thanks!!!

"Munna" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
Cirene
Guest
Posts: n/a
 
      06-08-2008
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
embeding databound DropDownList in FormView spoils DropDownList ev Lagrange ASP .Net Web Controls 1 01-17-2009 08:31 AM
databound custom controls vs composite databound custom controls rodchar ASP .Net 0 11-26-2007 03:51 PM
templated databound control problem - not showing databound Manu ASP .Net Web Controls 0 05-22-2006 09:46 AM
Urgent help with ItemTemplate (datagrid) - databound DropDownList VB Programmer ASP .Net 6 09-01-2004 07:08 PM
Re: DataGrid with a template column which contains a databound dropdownlist jm ASP .Net 0 05-14-2004 10:22 PM



Advertisments