C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

GridView


Posted Date: 10 Oct 2008      Posted By: Maheswari      Member Level: Gold     Points: 1   Responses: 4



Using GridView with Pagenumber (1 to 25)

i have database 2500.

while loading the page i want to retrieve 100 records from database into Gridview and if i click 2 nd Page in Gridview another 100 records (from 101 to 200) should view into GridView

but this is difficult

bcz while clicking 2nd page there 100 records only should retrieve from table only.
after that while clicking 3rd page then another 100 records only retrieve from table. like this i need..........
how to do





Responses

Author: divya    10 Oct 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 3

u can set page size to 100 as pagesize="100" and then on page index changing event write the code as
grid.pageindex=e.newpageindex and agai bind ur grid as u do.



Author: Mari raj k    10 Oct 2008Member Level: SilverRating: 2 out of 52 out of 5     Points: 6

1. set property of allowpaging as true,

2. set proerty of page size = 100

3. You can configure the page to show navigation by displaying numeric values for page numbers, which is default. Or you can set Mode property of PagerSetting to one of the following values.

NextPrevious A set of pagination controls consisting of Previous and Next buttons.

NextPreviousFirstLast A set of pagination controls consisting of Previous, Next, First, and Last buttons.

Numeric A set of pagination controls consisting of numbered link buttons to access pages directly.

NumericFirstLast A set of pagination controls consisting of numbered and First and Last link buttons.


Setting Page Size From Codebehind

So far I have been talking about how to set various property values at design time or on ASPX page. There are times when you have to configure the appearance of the grid view pager based on some conditions or data value only known at run time. For those times you can take help from code behind and specify the values in the implementation code itself. For example the following code from the attached project shows the page size of the grid view is changed based on the value user specifies in the text box.

protected void OnChangePageSize(Object sender, EventArgs e)
{
Int32 iPageSize = ctlGridView.PageSize;
if (Int32.TryParse(ctlPageSize.Text, out iPageSize))
{
ctlGridView.PageSize = iPageSize;
bindGridView();
}
}



Author: Abhi    10 Oct 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 6

<asp:datagrid runat="server" cssclass="gridClass" id="dgPatient"
width="389px" cellspacing="0"
cellpadding="0" allowsorting="True" autogeneratecolumns="false" datakeyfield="PK_PAT_ENC_ID"
showheader="true"
Height="36px"
PageSize="100" AllowPaging="true"

OnPageIndexChanged="dgPatient_PageIndexChanged"
OnItemDataBound="dgPatient_ItemDataBound" >

//--

//--

</asp:datagrid>


.aspx.cs






protected void dgPatient_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
{
dgPatient.CurrentPageIndex = e.NewPageIndex;
this.gridDatabind();
}

Thanks and Regards,
Abhay



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Ajax timer Control
Previous : Datagrid Update Command
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use