Wrox Programmer Forums
|
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 29th, 2009, 05:09 AM
Authorized User
 
Join Date: Apr 2007
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default Custom Pagin in GridView

Hello Friends,

I'm implementing custom paging in my GridView. Paging numbering(in-built paging numbering) does not display but it brings the records are queried . Below giving my code please let me know what changes i should make in my code. But if i use in-built paging(normal paging) then that's working fine......

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
lblMsg.Text = e.NewPageIndex.ToString();
int pageNumber=Convert.ToInt32(e.NewPageIndex);
int recordPerPage= 4;
int startRecord = (pageNumber) * recordPerPage + 1;
int maxRecord = startRecord + recordPerPage;

bindGridView1(startRecord,maxRecord);
}

public void bindGridView1(int startRecord,int maxRecord)
{
string connectionString = "server=.;database=Auto_New;uid=sa;pwd=;";

using(SqlConnection mCon = new SqlConnection(connectionString))
{
SqlCommand mDataCom = new SqlCommand();

mDataCom.Connection = mCon;

mDataCom.CommandType = CommandType.StoredProcedure;
mDataCom.CommandText = "SP_Select1";
mDataCom.Parameters.AddWithValue("@startRecord", startRecord);
mDataCom.Parameters.AddWithValue("@maxRecord", maxRecord);

SqlDataAdapter da = new SqlDataAdapter(mDataCom);
DataSet ds = new DataSet();
da.Fill(ds);

GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
}
}
 
Old July 29th, 2009, 07:45 AM
Authorized User
 
Join Date: Mar 2008
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to myself.panku
Default

Hi Friend,

u are not able to see the current page index inside gridview, this is the only issue with you....

Thanks
-Pankaj
__________________
Thanks
-Pankaj Bahuguna
 
Old July 29th, 2009, 07:48 AM
Authorized User
 
Join Date: Mar 2008
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to myself.panku
Default

one more thing is needed to see here please put the aspx code

<asp:Gridview.................></GridView>

that will really help to get the scenario......
__________________
Thanks
-Pankaj Bahuguna
 
Old July 29th, 2009, 08:46 AM
Authorized User
 
Join Date: Apr 2007
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here i'm giving my GridView code

<asp:GridViewID="GridView1"runat="server"AutoGenerateColumns="False"AllowPaging="True"onpageindexchanging="GridView1_PageIndexChanging"
PageSize="4"ondatabound="GridView1_DataBound">
<Columns>
<asp:BoundFieldDataField="RNo"HeaderText="RNO"/>
<asp:BoundFieldDataField="ID"HeaderText="ID"/>
<asp:BoundFieldDataField="Name"HeaderText="Name"/>
</Columns></asp:GridView>





Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView -- How do I do custom updates? mjwinberry ASP.NET 2.0 Basics 2 January 3rd, 2008 06:00 PM
pagin with access sh_57 Classic ASP Databases 0 April 18th, 2007 05:39 AM
Gridview custom buttons wirerider ASP.NET 2.0 Basics 2 February 5th, 2006 02:49 PM
Custom GridView bmains ASP.NET 2.0 Basics 0 August 8th, 2005 03:06 PM
Custom GridView (maybe?) bmains ASP.NET 2.0 Basics 0 April 18th, 2005 09:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.