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

Navigation issues

3 Answers 65 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James Shelton Agar
Top achievements
Rank 2
James Shelton Agar asked on 21 Oct 2009, 11:20 PM
There are a problem regarding to navigation and history point for me.
The needdatasource seems to be called prior than scriptmanager's Navigate event, thus when i addhistorypoint when changing page, view detail, and click the back button, it will reload twice and start with page 0 then the previous page.

any suggestions?

The design of grid as follows
                    <telerik:RadGrid SkinID="GridSkin" ID="AListingsGrid" runat="server" AllowPaging="True" 
                        AutoGenerateColumns="False" GridLines="None" AllowSorting="True" PageSize="10" 
                        ShowStatusBar="True" AllowCustomPaging="True" ShowHeader="false" ShowDesignTimeSmartTagMessage="False" 
                        EnableViewState="False"
                        <headercontextmenu enabletheming="True"
                            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
                        </headercontextmenu> 
                        <pagerstyle alwaysvisible="false" mode="NextPrevAndNumeric" seopagingquerystringkey="CurrentPage" /> 
                        <mastertableview allowcustomsorting="True" cellspacing="-1" enableviewstate="False"
                            <SortExpressions> 
                            </SortExpressions> 
                            <Columns> 
                                <telerik:GridTemplateColumn UniqueName="Image"
                                    <ItemTemplate> 
                                        <asp:Panel ID="PanelListings" runat="server" CssClass="display"
                                            <div class="PImg"
                                                <asp:HyperLink ID="lnkImghyper" runat="server"
                                                    <div class="ListingImg"
                                                        <div class="propertyImg"
                                                            <asp:Image ID="ImageListingPhoto" runat="server" /> 
                                                        </div> 
                                                        <asp:Image CssClass="PSoldImg" ID="imgSold" runat="server" ImageUrl="~/Images/sold.gif" 
                                                            Visible="false" /> 
                                                    </div> 
                                                </asp:HyperLink> 
                                            </div> 
                                            <div id="PropertyInfo"
                                                <span class="price"
                                                    <asp:Label ID="LblPrice" runat="server" Text="Label"></asp:Label></span<span class="PropertyAdd"
                                                        <asp:HyperLink ID="lnkGridSuburb" runat="server" Font-Bold="true"></asp:HyperLink> 
                                                    </span> 
                                                <br class="clear" /> 
                                                <asp:Label ID="lblAddress" CssClass="lstAddress" runat="server"></asp:Label> 
                                                <div class="adCopyTitle"
                                                    <asp:HyperLink ID="lnkAd" runat="server" Font-Bold="true"></asp:HyperLink> 
                                                </div> 
                                                <table class="listingsIcon"
                                                    <tr> 
                                                        <asp:Panel runat="server" ID="pnlBed"
                                                            <td> 
                                                                <asp:Label runat="server" ID="lblbed"></asp:Label> 
                                                                <asp:Image ID="Image6" runat="server" ImageUrl="~/Images/Stock/ADBed.png" alt="" 
                                                                    CssClass="propertiesIcon" /> 
                                                            </td> 
                                                        </asp:Panel> 
                                                        <asp:Panel runat="server" ID="pnlBath"
                                                            <td> 
                                                                <asp:Label runat="server" ID="lblShower"></asp:Label> 
                                                                <asp:Image ID="Image5" runat="server" ImageUrl="~/Images/Stock/ADBath.png" alt="" 
                                                                    CssClass="propertiesIcon" /> 
                                                            </td> 
                                                        </asp:Panel> 
                                                        <asp:Panel ID="pnlStudy" runat="server"
                                                            <td> 
                                                                <asp:Label ID="lblStudy" runat="server" Text=""></asp:Label> 
                                                                <asp:Image ID="Image11" runat="server" ImageUrl="~/Images/Stock/ADStudy.png" alt="" 
                                                                    CssClass="propertiesIcon" /> 
                                                            </td> 
                                                        </asp:Panel> 
                                                        <asp:Panel ID="PnlLivingIcon" runat="server" Visible="false"
                                                            <td> 
                                                                <asp:Label ID="LblCountLivingRoom" runat="server"></asp:Label> 
                                                                <asp:Image ID="Image4" runat="server" ImageUrl="~/Images/Stock/ADLounge.png" alt="" 
                                                                    CssClass="propertiesIcon" /> 
                                                            </td> 
                                                        </asp:Panel> 
                                                        <asp:Panel ID="pnlshowArea" runat="server"
                                                            <td> 
                                                                <asp:Label ID="lblshowArea" runat="server"></asp:Label> 
                                                                <asp:Image ID="Image12" runat="server" ImageUrl="~/Images/Stock/ADArea.png" alt="" 
                                                                    CssClass="propertiesIcon" /> 
                                                            </td> 
                                                        </asp:Panel> 
                                                        <asp:Panel ID="PnlGarageIcon" runat="server"
                                                            <td> 
                                                                <asp:Label ID="LblCountGarage" runat="server"></asp:Label> 
                                                                <asp:Image ID="Image3" runat="server" ImageUrl="~/Images/Stock/ADGarage.png" alt="" 
                                                                    CssClass="propertiesIcon" /> 
                                                            </td> 
                                                        </asp:Panel> 
                                                        <asp:Panel ID="PnlPoolIcon" runat="server"
                                                            <td> 
                                                                <asp:Label ID="LblCountPool" runat="server"></asp:Label> 
                                                                <asp:Image ID="Image2" runat="server" ImageUrl="~/Images/Stock/ADPool.png" alt="" 
                                                                    CssClass="propertiesIcon" /> 
                                                            </td> 
                                                        </asp:Panel> 
                                                        <asp:Panel ID="PnlAirconIcon" runat="server" Visible="false"
                                                            <td> 
                                                                <asp:Label ID="LblCountAircon" runat="server"></asp:Label> 
                                                                <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/Stock/aircon_icon.png" Width="30" 
                                                                    alt="" CssClass="propertiesIcon" /> 
                                                            </td> 
                                                        </asp:Panel> 
                                                    </tr> 
                                                </table> 
                                                <div class="Pdetail"
                                                    <asp:Label CssClass="Pdetail" ID="lnkDetail" runat="server" /> 
                                                </div> 
                                                <asp:Panel ID="Panel1" runat="server" Visible="false"
                                                    <span class="PTitle">ID#</span> <span class="PTitle"
                                                        <%#Eval("Href_No")%></span></asp:Panel> 
                                            </div> 
                                        </asp:Panel> 
                                    </ItemTemplate> 
                                </telerik:GridTemplateColumn> 
                            </Columns> 
                            <EditFormSettings> 
                                <PopUpSettings ScrollBars="None" /> 
                            </EditFormSettings> 
                        </mastertableview> 
                        <clientsettings> 
                            <Selecting AllowRowSelect="False" /> 
                            <Scrolling  AllowScroll="false" /> 
                        </clientsettings> 
                        <filtermenu enabletheming="True"
                            <CollapseAnimation Type="OutQuint" Duration="200" /> 
                        </filtermenu> 
                        <sortingsettings enableskinsortstyles="False" /> 
                        <statusbarsettings loadingtext="Loading Listings, please wait..." /> 
                    </telerik:RadGrid> 

and code calling
Private Sub Page_Init(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Init 
        'Add History handler 
        Dim RadScriptManager1 = DirectCast(Me.Master.FindControl("RadScriptManager1"), RadScriptManager) 
        AddHandler RadScriptManager1.Navigate, AddressOf RadScriptManager1_Navigate 
    End Sub 
 
    Private Sub AListingsGrid_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles AListingsGrid.NeedDataSource 
'Get datasource 
end sub 
 
    Private Sub RadScriptManager1_Navigate(ByVal sender As ObjectByVal e As System.Web.UI.HistoryEventArgs) 
        If Not String.IsNullOrEmpty(e.State("CurrentPage")) Then 
            AListingsGrid.CurrentPageIndex = CInt(e.State("CurrentPage")) 
        Else 
            AListingsGrid.CurrentPageIndex = 0 
        End If 
 AListingsGrid.DataSource = Nothing 
        AListingsGrid.Rebind() 
end sub 

and live demo as follows

thanks

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 22 Oct 2009, 09:41 AM
Hello James,

Please have in mind that you should never call the Rebind() method in a NeedDataSource event handler.You should never call DataBind() as well when using advanced data-binding through NeedDataSource.
Find more information in the following helps article:
Advanced Data-binding (using NeedDataSource event)

Sincerely yours,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
James Shelton Agar
Top achievements
Rank 2
answered on 22 Oct 2009, 08:45 PM
Hi, there was no Rebind() method in a NeedDataSource and no DataBind() as well when using advanced data-binding through NeedDataSource throughout the code. I just hide the codes which gets the data which is unnecessary to show.

I think it is asp.net's problem that's calling onload before onnavigate.

0
Pavlina
Telerik team
answered on 23 Oct 2009, 11:53 AM
Hi James,

I suggest that you check on Page_Load if the page url contains current page key and if so you should set the proper current page index of RadGrid control.

I hope this helps.

Kind regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
James Shelton Agar
Top achievements
Rank 2
Answers by
Pavlina
Telerik team
James Shelton Agar
Top achievements
Rank 2
Share this question
or