questo sarebbe il vecchio medoto asp......
Il problema sta nel fatto che il pager del gridview, invia dei postback alla pagina, mentre mettendo i parametri sulla querystring, dovresti trasformare i linkbutton del pager in semplici link. Questo vuol dire che ti salta il meccanismo del viewstate (se ne fai uso).
Una mia idea.
un pager custom lato aspx così:
codice:
<PagerTemplate>
<table width="100%">
<tr>
<td style="text-align: right">
<asp:PlaceHolder ID="PlaceHolder1" runat="server" />
</td>
</tr>
</table>
</PagerTemplate>
una gestione delle pagine lato codice così:
codice:
protected void Page_Load(object sender, EventArgs e)
{
string page = string.Empty;
if (Request.QueryString["page"] != null)
{
page = Request.QueryString["page"].ToString();
GridView1.PageIndex = int.Parse(page) - 1;
}
}
protected void GridView1_DataBound(object sender, EventArgs e)
{
SetPaging();
}
private void SetPaging()
{
GridViewRow row = GridView1.BottomPagerRow;
for (int i = 1; i < GridView1.PageCount; i++)
{
string urlWithPage = "{0}?page={1}";
string currenturl = Request.Url.AbsolutePath;
HyperLink hl = new HyperLink();
hl.Text = i.ToString();
hl.NavigateUrl = string.Format(urlWithPage, currenturl, i.ToString());
hl.ToolTip = "Page " + i.ToString();
if (i == GridView1.PageIndex + 1)
{
hl.BackColor = Color.BlanchedAlmond;
hl.Style[HtmlTextWriterStyle.TextDecoration] = "none";
}
PlaceHolder place = row.FindControl("PlaceHolder1") as PlaceHolder;
place.Controls.Add(hl);
Label lbl = new Label();
lbl.Text = " ";
place.Controls.Add(lbl);
}
}