Click here to Skip to main content
16,004,778 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I am trying to implement filter option in my RadGrid. But I am unable to do that.
Whenever I am filtering the grid, the data of grid goes off. This grid I binded dynamically.

Here is the code:

XML
<telerik:RadGrid runat="server" ID="rgBooks" AllowPaging="True"
                AllowSorting="True" AutoGenerateColumns="False"
                onpageindexchanged="rgBooks_PageIndexChanged"
                onpagesizechanged="rgBooks_PageSizeChanged" CellSpacing="0"
                GridLines="None" oneditcommand="rgBooks_EditCommand"
                ongroupschanging="rgBooks_GroupsChanging" onsortcommand="rgBooks_SortCommand"
                ShowGroupPanel="True" oncancelcommand="rgBooks_CancelCommand"
                onitemupdated="rgBooks_ItemUpdated"
                onupdatecommand="rgBooks_UpdateCommand"
                ondeletecommand="rgBooks_DeleteCommand" oninsertcommand="rgBooks_InsertCommand"
                onitemcommand="rgBooks_ItemCommand" AllowFilteringByColumn="True"  >

                <ClientSettings AllowDragToGroup="True">
                    <Selecting CellSelectionMode="None"></Selecting>
                </ClientSettings>
                <MasterTableView CommandItemDisplay="Bottom" AllowFilteringByColumn="true">

                    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"/>
                    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"/>
                    <Columns>
                        <telerik:GridTemplateColumn HeaderText="Book ID" DataField="BookID" UniqueName="BookID" CurrentFilterFunction="EqualTo" AutoPostBackOnFilter="true" DataType="System.Int32" >
                            <ItemTemplate>
                                <asp:Label ID="lblBookID" runat="server" Text='<%#Eval("BookID") %>' />
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Title" UniqueName="Title">
                            <ItemTemplate>
                                <asp:Label ID="lblTitle" runat="server" Text='<%#Eval("Title") %>' />
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtTitle" runat="server" Text='<%#Eval("Title") %>' />
                                <asp:RequiredFieldValidator ID="rfvTitle" runat="server" ForeColor="Red"
                                    ErrorMessage="Please Enter the Title" ControlToValidate="txtTitle"/>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Publisher Name" UniqueName="PublisherName" >
                            <ItemTemplate>
                                <asp:Label ID="lblPublisherName" runat="server" Text='<%#Eval("PublisherName") %>' />
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtPublisherName" runat="server" Text='<%#Eval("PublisherName") %>' />
                                <asp:RequiredFieldValidator ID="rfvPublisherName" runat="server" ForeColor="Red"
                                    ErrorMessage="Please Enter the Publisher Name" ControlToValidate="txtPublisherName"/>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Published Date" UniqueName="PublishedDate">
                            <ItemTemplate>
                                <asp:Label ID="lblPublishedDate" runat="server" Text='<%#Eval("PublishedDate") %>' />
                            </ItemTemplate>
                            <EditItemTemplate>
                                 <asp:TextBox ID="txtPublishedDate" runat="server" Text='<%#Eval("PublishedDate") %>'
                                    onKeyPress='Javascript:return false;'/>
                                 <cc1:CalendarExtender ID="cePublishedDate" TargetControlID="txtPublishedDate"
                                    runat="server"/>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridEditCommandColumn UniqueName="EditCommandColumn"
                            HeaderText="Edit" ButtonType="ImageButton"/>
                        <telerik:GridButtonColumn ConfirmText="Are You Sure Want To Delete?" ConfirmDialogType="Classic"
                            ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                            UniqueName="DeleteRow" HeaderText="Delete" CommandArgument="BookID">
                            <ItemStyle HorizontalAlign="Center" />
                        </telerik:GridButtonColumn>
                    </Columns>
                    <CommandItemSettings AddNewRecordText="Add New" ShowRefreshButton="true" RefreshText="Refresh" />
                        <CommandItemStyle Height="30px" />
                    <EditFormSettings>
                        <EditColumn UniqueName="EditCommand" />
                    </EditFormSettings>
                </MasterTableView>
                <FilterMenu EnableImageSprites="False"></FilterMenu>
            </telerik:RadGrid>


Please help me out of this problem.
Thanx in advance..
Posted

see if this might help you (from codeproject)

Filter a DataGrid using a Foreign Key Combobox[^]
 
Share this answer
 
Just Add NeedDataSorceEvent of RadGrid and keep all code which are using in binding radgrid except Radgrid1.databind()

and set on aspx page allowfilteringcolumn=true;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900