开发者

Pagination in ListViewByQuery web part

I have written a web part that use ListViewByQuery to display the items based on query provided. Everything work perfect except pagination.

When I specify rowLimit it is displaying me only first set of record and pagination control is not visible so I could not able to move to next set of rec开发者_如何学Cords.


The problem is that when you click on the paged button 1-2 it will postback adding some values in query string.

I accidentally remove the view=. query string from the URL and hit enter to get the results.

So what I did is as follows

if (!string.IsNullOrEmpty(Request.QueryString["View"]))

{
   string queryString = string.Empty;
   foreach (string key in Request.QueryString.Keys)
   {
     if (key.ToLower() != "view")
       queryString += key + "=" + Request.QueryString[key] + "&";
   }

SPUtility.Redirect(Request.Url.GetLeftPart(UriPartial.Path), SPRedirectFlags.Default, HttpContext.Current,queryString);
 return;

}


Great answer Muhammad - after removing the view key and value, the link works fine.
However the line SPUtility.Redirect(.. didn't work for me.
Instead, as I put your code inside CreateChildControls() I used:

 this.Context.Response.Redirect(this.Context.Request.Url.GetLeftPart(UriPartial.Path) + "?" + queryString);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜