gridview paging format Problem
Hi All,
I'm using a gridview control with paging. I'm having difficulty getting exactly what I want with the formatting for paging. i.e. I can get
Next Previous
1,2,3,4 .....
at the bottom of the grid for paging, but I cannot get
<previous 1,2,3,4,5 Next>
Type formatting, does anyone know how to do this.
Re: gridview paging format Problem
I don't know if it is possible to modify the default pager settings in GridView, but you can manually create a pager for a GridView.
1. Override Render() function of the GridView
2. Generate the Hyperlinks or LinkButtons, to indicate your Previous, Page Number, Next command
3. Put the following script in the onClick event
LinkButton1.OnClientClick = "__doPostBack('" + this.ClientID.Replace("_", "$") + "','Page$" + n.ToString() + "')";
4. Render the controls using the LinkButton1.RenderControl(writer) command.
where n is the variable indicating the Page Number.
Step 3 is quite trickly instead, becauase the GridView will accept the Page$n in the event argument of a post back, and then switch the page number based on it.
You will discover it after inspecting how the page number works in ordinary paged gridview.