Having trouble creating a dynamic pagertemplate. I want it like this
"Prev 1 2 3 4 Next". The numerically portion being the dynamic part
based on the record count.
I can generate it, but can't get any events to fire.
Is it possible to do? I've tried creating them int he RowCreated
event, DataBound and my own PagerTemplate, but nothing seems to work.
Here is one snippet that I've tried. It causes a postback, but it
isn't handled by the gridview.
protected void gvSearchResults _RowCreated(obj ect sender,
GridViewRowEven tArgs e)
{
if( e.Row.RowType == DataControlRowT ype.Pager)
{
// Get the pager row.
GridViewRow pagerRow = e.Row;
// Get the pager row.
Panel pagesPanel =
(Panel)pagerRow .FindControl("P agesPanel");
//Panel pagesPanel = pagesPanel;
LinkButton myButton = new LinkButton();
myButton.Text = "Prev";
myButton.Comman dName = "Page";
myButton.Comman dArgument = "Prev";
myButton.ID = "PrevPage";
pagesPanel.Cont rols.Add(myButt on);
for (int i = 1; i < ((GridView)send er).PageCount + 1; i++)
{
myButton = new LinkButton();
myButton.Text = String.Format(" {0} ", i);
myButton.Comman dName = "Page";
myButton.Comman dArgument = i.ToString();
myButton.ID = "Page" + i;
pagesPanel.Cont rols.Add(myButt on);
}
myButton = new LinkButton();
myButton.Text = "Next";
myButton.Comman dName = "Page";
myButton.Comman dArgument = "Next";
myButton.ID = "NextPage";
pagesPanel.Cont rols.Add(myButt on);
}
}