I have a listing page which contains a ListView
control associated to DataPager
control.
I have also implemented ASP.Net WebForms URL routing
. initially when the user visits the page the url comes like
www.domain.com/entity/list
When i click on DataPager
Page button i want the URL
to be like
www.domain.com/entity/list/{Page_Number}
I have handled the DataPager_PagePropertiesChanging event in which i get the Current Page Index like following
protected void lvRestaurants_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
{
CurrentPage = ((RestaurantPager.StartRowIndex) / RestaurantPager.MaximumRows) + 1;
//Response.RedirectToRoute("browserestaurantbypage", new { id_pg = CurrentPage });
//RestaurantPager.GetRouteUrl("browserestaurantbypage", new { id_pg = CurrentPage - 1 });
Response.RedirectToRoute("browserestaurantbypage", new { id_pg = CurrentPage});
}
is it ok to call Response.RedirectToRoute
in above event because i get the page isn't Redirecting Properly error in firefox.
my DataPager Control looks like following
<asp:DataPager ID="RestaurantPager" runat="server" QueryStringField='<%#Eval("ID_Restaurant") %>'
PagedControlID="lvRestaurants" PageSize="10">
<Fields>
<asp:NextPreviousPagerField PreviousPageText="« previous" ShowFirstPageButton="false"
ShowNextPageButton="False" ShowPreviousPageButton="true" />
<asp:NumericPagerField ButtonType="Link" CurrentPageLabelCssClass="current" ButtonCount="4" />
<asp:NextPreviousPagerField NextPageText="Next »" ShowLastPageButton="false"
ShowNextPageButton="true" ShowPreviousPageButton="False" />
</Fields>
</asp:DataPager>
would you please guide me how to achieve this . Please let me know if anything is unclear in question.