Hi,
I'm having a problem with radgrid and i couldn't find a general solution. Here is the scenario:
I have a search page that binds results to grid. pagesize=10. first query returns 11 elements so grid is 2 pages. i'm selecting second page then search again which returns 1 element. here is the problem, radgrid stuck at second page and i don't want to show "No records to display" message, i just want to reset page to 1.
I can do it by:
| protected void btnSearch_Click(object sender, EventArgs e) |
| { |
| grdBank.CurrentPageIndex = 0; |
| grdBank.Rebind(); |
| } |
however, i'm using this grid in more than 100 pages which all have this problem. i don't want to put this code in every page. So i created my own custom pager as described here: http://www.telerik.com/help/aspnet-ajax/grdprogrammaticpagercustomization.html but this also has same problem.
i tried to reset page by "e.Item.OwnerTableView.CurrentPageIndex = 0;" in "protected override void OnItemEvent(GridItemEventArgs e)" which works as expected but caused another problem that i can't go to page 3 which is also expected...
how can i solve it in pager? on which event should i reset page?
Thanks

| <CommandItemTemplate> |
| <telerik:RadToolBar ID="RadToolBar1" runat="server" CausesValidation="False" Skin="Sunset" |
| OnClientButtonClicking="OnClientButtonClicking" AutoPostBack="True" |
| style="display:block; float: none"> |
| <Items> |
| <telerik:RadToolBarButton runat="server" Text="Add New" |
| CommandName="AddNew" Width="20%"> |
| </telerik:RadToolBarButton> |
| <telerik:RadToolBarButton runat="server" Text="Delete" |
| CommandName="DeleteFile" Width="20%"> |
| </telerik:RadToolBarButton> |
| <telerik:RadToolBarButton runat="server" Text="Refresh" |
| CommandName="Refresh" Width="20%" > |
| </telerik:RadToolBarButton> |
| <telerik:RadToolBarButton runat="server" Text="AutoRefresh OFF" |
| CommandName="Autorefresh" AllowSelfUnCheck="True" CheckOnClick="True" Width="20%"> |
| </telerik:RadToolBarButton> |
| <telerik:RadToolBarDropDown runat="server" Text="Filter Files" > |
| <Buttons> |
| <telerik:RadToolBarButton runat="server" Text="All Files" CommandName="FilterAllFile" Width="20%"> |
| </telerik:RadToolBarButton> |
| <telerik:RadToolBarButton runat="server" Text="Ready Files" CommandName="FilterReadyFile"> |
| </telerik:RadToolBarButton> |
| <telerik:RadToolBarButton runat="server" Text="Error Files" CommandName="FilterErrorFile"> |
| </telerik:RadToolBarButton> |
| <telerik:RadToolBarButton runat="server" Text="Processing Files" CommandName="FilterProcessingFile"> |
| </telerik:RadToolBarButton> |
| </Buttons> |
| </telerik:RadToolBarDropDown> |
| </Items> |
| </telerik:RadToolBar> |
| </CommandItemTemplate> |
<telerik:GridTemplateColumn DataField="SellPrice"
DataType="System.Decimal" HeaderText="Sell Price"
SortExpression="SellPrice" UniqueName="SellPrice">
<EditItemTemplate>
<asp:TextBox ID="SellPriceTextBox" runat="server"
Text='<%# Bind("SellPrice") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="SellPriceLabel" runat="server"
Text='<%# Eval("SellPrice") %>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>