N
.nLL
Hi, i am using Intelligencia.UrlRewriter on a page that has a listview
control and datapager. Data paging works fine but pager uses real url
instead of rewritten one.
if url rewrite is /products-page-1.aspx?page=2
and real url
/products.aspx?id=1
pager uses /products.aspx?id=1&page=2
i want to be able to set it so pager uses /products-page-1.aspx?page=2
I have found some info on the net and got it working with below function
protected void VideosDataPager_PreRender(object sender, EventArgs e)
{
DataPager pager = (DataPager)Page.FindControl("VideosDataPager");
int count = pager.TotalRowCount;
int pageSize = pager.PageSize;
int pagesCount = count / pageSize + (count % pageSize == 0 ? 0 : 1);
int pageSelected = pager.StartRowIndex / pageSize + 1;
for (int i = 1; i <= pagesCount; ++i)
{
if (pageSelected != i)
{
HyperLink link = new HyperLink();
link.NavigateUrl = "/products--page--" + catnameforPaging +
"--1.aspx?p=" + i.ToString();
link.Text = i.ToString();
VideosList.Controls.Add(link);
}
else
{
Literal lit = new Literal();
lit.Text = i.ToString();
VideosList.Controls.Add(lit);
}
Literal space = new Literal();
space.Text = " ";
VideosList.Controls.Add(space);
}
}
but with this i get 2 datapagin and if i remove VideosDataPager from the
page function stops working.
Is ther any way to change target url on datapager?
control and datapager. Data paging works fine but pager uses real url
instead of rewritten one.
if url rewrite is /products-page-1.aspx?page=2
and real url
/products.aspx?id=1
pager uses /products.aspx?id=1&page=2
i want to be able to set it so pager uses /products-page-1.aspx?page=2
I have found some info on the net and got it working with below function
protected void VideosDataPager_PreRender(object sender, EventArgs e)
{
DataPager pager = (DataPager)Page.FindControl("VideosDataPager");
int count = pager.TotalRowCount;
int pageSize = pager.PageSize;
int pagesCount = count / pageSize + (count % pageSize == 0 ? 0 : 1);
int pageSelected = pager.StartRowIndex / pageSize + 1;
for (int i = 1; i <= pagesCount; ++i)
{
if (pageSelected != i)
{
HyperLink link = new HyperLink();
link.NavigateUrl = "/products--page--" + catnameforPaging +
"--1.aspx?p=" + i.ToString();
link.Text = i.ToString();
VideosList.Controls.Add(link);
}
else
{
Literal lit = new Literal();
lit.Text = i.ToString();
VideosList.Controls.Add(lit);
}
Literal space = new Literal();
space.Text = " ";
VideosList.Controls.Add(space);
}
}
but with this i get 2 datapagin and if i remove VideosDataPager from the
page function stops working.
Is ther any way to change target url on datapager?