Search_Blog



 

View Blog

Dec 17

Written by: IOTAP ::-- DotNet Team
12/17/2007 12:24 PM

Customizing Grid View Pager

Asp.net 2.0 Gridview control has a property called Pagerstyle which allows us to specify custom styles for the gridview pager. Gridview control renders pager as a separate table within the main table. The problem with pagerstyle is that it applies the style to the row containing the pager table instead individual cells of the pager table. Because of this the style property set for the pagerstyle will not be applied correctly in some situations. For overcoming this limitation we need to write code for applying style to individual cells.  Gridview has properties BottomPagerRow and TopPagerRow for accessing the pager controls programatically. This properties will give reference to the table row that has the pager table within. The pager table will be of type Pagertable and has only one row with cells for individual page numbers. Once we get a refernce to the row we can loop through individual cells and apply ccustom style for them. The following code shows how to apply custom style to grid view pager

Dim pagerTable As Table = CType(GridView1.BottomPagerRow.Cells(0).Controls(0), Table)

        Dim TC As TableCell

        For Each TC In pagerTable.Rows(0).Cells

            TC.Style.Add("font-size", "20pt")

            TC.ForeColor = Drawing.Color.Bisque

        Next

Cheers J

Tags:

Your name:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment    Cancel