Having "ALL ITEMS" in databound dropdownlist

Discussion in 'ASP .Net' started by Cirene, Jun 6, 2008.

  1. Cirene

    Cirene Guest

    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!
    Cirene, Jun 6, 2008
    #1
    1. Advertising

  2. Cirene

    Munna Guest

    On Jun 7, 1:53 am, "Cirene" <> 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
    Munna, Jun 7, 2008
    #2
    1. Advertising

  3. Cirene

    Cirene Guest

    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" <> wrote in message
    news:...
    On Jun 7, 1:53 am, "Cirene" <> 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
    Cirene, Jun 8, 2008
    #3
  4. Cirene

    Munna Guest

    Munna, Jun 8, 2008
    #4
  5. Cirene

    Cirene Guest

    Cirene, Jun 8, 2008
    #5
  6. Cirene

    Cirene Guest

    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" <> wrote in message
    news:...
    > 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
    Cirene, Jun 8, 2008
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Iain
    Replies:
    3
    Views:
    918
  2. rodchar
    Replies:
    0
    Views:
    380
    rodchar
    Nov 26, 2007
  3. Anjan Bhowmik
    Replies:
    1
    Views:
    460
    Misbah Arefin
    Feb 14, 2008
  4. Manu
    Replies:
    0
    Views:
    159
  5. Lagrange
    Replies:
    1
    Views:
    544
    Lagrange
    Jan 17, 2009
Loading...

Share This Page