C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Paging


Posted Date: 15 Oct 2008    Resource Type: Code Snippets    Category: Tools

Posted By: Meetu Choudhary       Member Level: Gold
Rating:     Points: 15



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();
}
}
}




==
Thanks and Regards
Meetu Choudhary
-
http://www.dotnetspider.com/sites/20/-Learn-ASP-Net.aspx
http://www.dotnetspider.com/sites/21/-DotNet-Expertise.aspx


Attachments

  • Paging (21842-15336-pagin.zip)



  • Responses


    No responses found. Be the first to respond and make money from revenue sharing program.

    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Paging in gridview  .  Paging  .  Customized paging in gridview  .  Customized paging  .  

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: Three Layer Architecture For Web Applications
    Previous Resource: Calling Codebehind funtion - Easy with Java Script
    Return to Discussion Resource Index
    Post New Resource
    Category: Tools


    Post resources and earn money!
     
    Related Resources



    dotNet Slackers   BizTalk Adaptors    Web Design

    fax server

    Contact Us    Privacy Policy    Terms Of Use