How to filter a grid view with a RadioBUttonList and Where Clausole

1.6k views Asked by At

I use C# in ASP.NET 4.

I have a GridView and an EntityDataSource for binding it with the DataBase.

Source DB Table contains a Bool Column (0,1).

I would like to filter the result in the GridView using a RadioList button or similar.

Adding the WhereParameters to the Entity Set I get an error:

String was not recognized as a valid Boolean. 

Any idea how to solve it? Thanks

    <WhereParameters>
        <asp:ControlParameter ControlID="uxFilterMessageTypeSelector" 
            Name="TypeMessage" PropertyName="SelectedValue" Type="String" />
        <asp:ControlParameter ControlID="uxFilterIsReplied" Name="IsReplied" 
            PropertyName="SelectedValue" DbType="Boolean" />
    </WhereParameters>

    <asp:RadioButtonList ID="uxFilterIsReplied" runat="server" AutoPostBack="True">
        <asp:ListItem Value="Y">1</asp:ListItem>
        <asp:ListItem Value="F">0</asp:ListItem>
    </asp:RadioButtonList>
1

There are 1 answers

0
MAW74656 On BEST ANSWER

Change your RadioButtonList to the following:

<asp:RadioButtonList ID="uxFilterIsReplied" runat="server" AutoPostBack="True">
    <asp:ListItem Value="True">1</asp:ListItem>
    <asp:ListItem Value="False">0</asp:ListItem>
</asp:RadioButtonList>

Then the String will be a recognized Boolean value.