Can CheckBoxList items be used in SelectParameters of ODS

Discussion in 'ASP .Net' started by Bogdan, Sep 25, 2008.

  1. Bogdan

    Bogdan Guest

    Hi,

    I have a CheckBoxList on a page and an Object Data Source which expects
    values from the list as its select parameters. Is there a way to
    declaratively define select parameters to reference items in the check box
    list?

    Example:
    <asp:CheckBoxList ID="cblTypes" runat="server" AutoPostBack="True"
    RepeatDirection="Horizontal" RepeatLayout="Flow" CssClass="legend"
    onselectedindexchanged="cblTypes_SelectedIndexChanged">
    <asp:ListItem Selected="True" Value="1">Type1</asp:ListItem>
    <asp:ListItem Value="2">Type2</asp:ListItem>
    <asp:ListItem Value="1">Type3</asp:ListItem>
    </asp:CheckBoxList>

    [...]

    <asp:ObjectDataSource ID="odsElements" runat="server"
    OldValuesParameterFormatString="{0}"
    SelectMethod="GetElementsByUserId" TypeName="ElementsBLL">
    <SelectParameters>
    <asp:SessionParameter Name="userId" SessionField="UserId" Type="String" />
    [...]
    </SelectParameters>
    </asp:ObjectDataSource>

    The BLL's select method has the following signature:
    public Elements.ElementDataTable ElementsBLL.GetElementsByUserId(string
    userId, short type1, short type2, short type3)

    If this cannot be done declaratively then what is the best approach if the
    ODS provides data to a GridView control?

    Thanks,
    Bogdan
     
    Bogdan, Sep 25, 2008
    #1
    1. Advertising

  2. Bogdan

    Louis Somers Guest

    Unfortunately the ListItem class is a sealed class.
    You cannot inherit from it and add any new preoperties to it.

    Again unfortunately, it also does not have any 'tag' property of type Object
    on which you would hang your custom class with metadata.

    You would have to whrite your own CheckBoxList component, or get a 3rd party
    one.

    "Bogdan" wrote:

    > Hi,
    >
    > I have a CheckBoxList on a page and an Object Data Source which expects
    > values from the list as its select parameters. Is there a way to
    > declaratively define select parameters to reference items in the check box
    > list?
    >
    > Example:
    > <asp:CheckBoxList ID="cblTypes" runat="server" AutoPostBack="True"
    > RepeatDirection="Horizontal" RepeatLayout="Flow" CssClass="legend"
    > onselectedindexchanged="cblTypes_SelectedIndexChanged">
    > <asp:ListItem Selected="True" Value="1">Type1</asp:ListItem>
    > <asp:ListItem Value="2">Type2</asp:ListItem>
    > <asp:ListItem Value="1">Type3</asp:ListItem>
    > </asp:CheckBoxList>
    >
    > [...]
    >
    > <asp:ObjectDataSource ID="odsElements" runat="server"
    > OldValuesParameterFormatString="{0}"
    > SelectMethod="GetElementsByUserId" TypeName="ElementsBLL">
    > <SelectParameters>
    > <asp:SessionParameter Name="userId" SessionField="UserId" Type="String" />
    > [...]
    > </SelectParameters>
    > </asp:ObjectDataSource>
    >
    > The BLL's select method has the following signature:
    > public Elements.ElementDataTable ElementsBLL.GetElementsByUserId(string
    > userId, short type1, short type2, short type3)
    >
    > If this cannot be done declaratively then what is the best approach if the
    > ODS provides data to a GridView control?
    >
    > Thanks,
    > Bogdan
    >
    >
    >
     
    Louis Somers, Sep 26, 2008
    #2
    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. John Smith
    Replies:
    1
    Views:
    1,238
    Brock Allen
    Jun 17, 2005
  2. Replies:
    2
    Views:
    2,695
    gella
    Mar 29, 2006
  3. Mike P

    GridView SelectParameters

    Mike P, May 30, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    23,708
    Brock Allen
    Jun 1, 2006
  4. Bart Van Hemelen
    Replies:
    2
    Views:
    4,693
    Bart Van Hemelen
    Sep 4, 2006
  5. Casey Hawthorne
    Replies:
    1
    Views:
    728
    Arne Vajhøj
    Mar 18, 2009
Loading...

Share This Page