This is a migrated thread and some comments may be shown as answers.

Custom Paging, and filtering using NeedDataSource (Advance Binding)

0 Answers 165 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Chirag asked on 07 May 2017, 10:18 AM


In my application I want to display simple grid with paging and filtering functionality. I am using custom paging for pagination of the grid.

My NeedDataSoure look like this

protected void rgList_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)

 Meeting360Entities db = new Meeting360Entities();
            var query = from c in db.Committees
                        select c;
            var Data = query.ToList();
            rgList.DataSource = Data.Skip(rgList.CurrentPageIndex * rgList.PageSize).Take(rgList.PageSize); // This line will selects records need to display on screen.  
            rgList.VirtualItemCount = Data.Count;


Like my above code in want select filtered data from data base. So how can in add WHERE clause into my linq query.

     <telerik:RadGrid ID="rgList" runat="server" AutoGenerateColumns="false" OnItemCommand="rgList_ItemCommand" GridLines="None"  
                                    ClientSettings-EnableRowHoverStyle="true" PagerStyle-Position="Bottom" AllowPaging="True" AllowCustomPaging ="true" PageSize="10" OnNeedDataSource="rgList_NeedDataSource"
                                    <MasterTableView DataKeyNames="CommitteeID" ClientDataKeyNames="CommitteeID">
                                            <telerik:GridBoundColumn DataField="CommitteeID" HeaderText="CommitteeID" UniqueName="CommitteeID" Visible="false">
                                            <telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name" UniqueName="Name" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" ShowFilterIcon="false">
                                                    <telerik:RadButton ID="btnEdit" runat="server" CommandArgument='<% #Eval("CommitteeID")%>' CommandName="ItemEdit" Text="Edit"></telerik:RadButton>
                                        <Selecting AllowRowSelect="true"></Selecting>

No answers yet. Maybe you can help?

Asked by
Top achievements
Rank 1
Share this question