This is a sample of customized Paging the concept implements the logic used in Google for paging the page numbers increases and decreases as in Google.. I have seen that logic and tires to implement it some how i succeeded and now i am sharing it with you all..
in this i have used a menu bar for the customized paging in the pager of a grid view....
the piece of code for the .cs file is as follows and for .aspx files and .cs files please go through the attachments..
using System; using System.Collections; using System.Configuration; using System.Data; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts;
public partial class Default2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) {
binding(); } } private void binding() { DataTable tblData = new DataTable(); DataColumn col1 = new DataColumn("Data1"); tblData.Columns.Add(col1);
for (int i = 1; i <= 1500; i++) { DataRow dr = tblData.NewRow(); dr["Data1"] = i; tblData.Rows.Add(dr); } GridView1.DataSource = tblData; GridView1.DataBind(); } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Pager) { Menu pgmenu =(Menu) e.Row.FindControl("Menu1"); int startno, endno; int selectedpgeno = -1; if (ViewState["selectedpgno"] == null) { startno = 1; endno = startno + 9; } else { selectedpgeno = Convert.ToInt32(ViewState["selectedpgno"]); if ((selectedpgeno - 10) <= 0) { startno = 1; endno = selectedpgeno + 9; } else { startno = selectedpgeno - 10; endno = selectedpgeno + 9; } }
for (int i = startno; i <= endno; i++) { pgmenu.Items.Add(new MenuItem(i.ToString(), (i - 1).ToString())); } } } protected void Menu1_MenuItemClick(object sender, MenuEventArgs e) { ViewState.Add("selectedpgno", e.Item.Text); GridView1.PageIndex = Convert.ToInt32(e.Item.Value); binding(); } protected void Navigate(object sender, CommandEventArgs e) { if (e.CommandName == "Next") { ViewState.Add("selectedpgno", GridView1.PageIndex + 1); GridView1.PageIndex = Convert.ToInt32(GridView1.PageIndex + 1); binding(); } } }
AttachmentsPaging (540-16241-Pagin.zip)
|
| Author: Gaurav Aroraa | Member Level: Gold | Revenue Score:  |
Great work! Its a really helpful to those who are facing such kind of problems.
Keep it up!
|
| Author: guru prasad | Member Level: Gold | Revenue Score:  |
Nice work Meetu,
Keep going......
|
| Author: Johan | Member Level: Gold | Revenue Score:  |
its really good
|
| Author: Prashanthi | Member Level: Silver | Revenue Score:  |
Nice Coding.
|
| Author: sandeep Avh | Member Level: Gold | Revenue Score:   |
code that u send not working properly.
i chnage some code loop only upto 150.
it showing me more than 15 link.
find attached screnshot.
screenshot.doc |