ASP.NET
  Home arrow ASP.NET arrow Page 3 - Working with DataGrids
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Working with DataGrids
By: JB Reddy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 32
    2004-05-17

    Table of Contents:
  • Working with DataGrids
  • A Simple Data Display
  • How to Add Paging to the DataGrid
  • Navigate Page
  • Adding Edit Functionality to the DataGrid

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Working with DataGrids - How to Add Paging to the DataGrid


    (Page 3 of 5 )

    To make our above DataGrid display paging, we have to adjust simple properties -- simply add attributes [ AllowPaging="true" onPageIndexChanged="NavigatePage" ] at Declaration so that after these properties, your DataGrid declaration looks like:

    <Asp:DataGrid Id="MyGrid" runat="Server" AllowPaging="true" onPageIndexChanged="NavigatePage" />

    Here NavigatePage is the Method which responds when a user clicks on the page number. I will explain it in a moment. Before that in page load, we have to adjust DataGrid properties like this:

    Public Sub Page_Load()
         If (not isPostBack) then
     MyGrid.PageSize=10
     MyGrid.PagerStyle.Mode=PagerMode.NumericPages
     MyGrid.CurrentPageIndex=0
            LoadData()
         end if
    End Sub

    Assign the page size (I:e How many rows per page),  page style and page index.

    Page indexing will be in numerical mode for most of the applications, but the time comes when page indexing also exceeds more than one row; it won't look nice in that case. To overcome this we have "PagerStyle" Property.

    Here page mode implies whether you want numerical page index or just "Next" "Previous" style. PagerStyle.Mode=PagerMode.NumericPages gives the numerical index at the bottom of the Grid.

    PagerStyle.Mode= PagerMode.NextPrev provides "Next" and "Previous" hyperlinks at the bottom of the Grid. By default, the indexing will be aligned to left; to make right aligned, just add the attribute PagerStyle-HorizontalAlign=”Right”  at Declaration so that the page indexing will be right aligned.

    In case of PrevNext mode we can change the text also with properties like:

    MyGrid,PagerStyle.NextPageText= ”MoveNext”
    MyGrid.PagerStyle.PrevPageText=” MoveBack”

    More ASP.NET Articles
    More By JB Reddy


     

    ASP.NET ARTICLES

    - More Advanced ASP.NET 3.5 Functions and Subr...
    - ASP.NET 3.5 Functions and Subroutines
    - Coding an IQ Test with Conditionally Driven ...
    - Developing Conditionally Driven Event Handle...
    - ASP.NET 3.5 Debugging Using Visual Web Devel...
    - Understanding Event Handlers in ASP.NET 3.5
    - Building a Web Form in ASP.NET and PHP: a Co...
    - Inserting Data into a Microsoft SQL 2008 Dat...
    - Creating an ASP.NET Dynamic Web Page Using M...
    - Retrieving Data from Microsoft SQL Server 20...
    - Building ASP.NET Web Forms to Use a MySQL Da...
    - Creating an ASP.NET Database using MS SQL 20...
    - Building an ASP.NET Website Using Include Ta...
    - Create ASP.NET Web Forms to Use a Microsoft ...
    - Editing Web Design Layout in Visual Web Deve...





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek