Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataGrid Paging - Display
Message
From
22/06/2005 11:19:09
 
 
To
21/06/2005 19:10:56
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
ASP.NET
OS:
Windows 2000 SP4
Database:
MS SQL Server
Miscellaneous
Thread ID:
01025307
Message ID:
01025483
Views:
14
This message has been marked as a message which has helped to the initial question of the thread.
Al,

This is in Vb but I am sure you can translate to C# if you need to. you should just need to change the alignment and the label text to say "Page:" or whatever.

Paul
 Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemCreated
        'Get the created item
        Dim itemType As ListItemType = e.Item.ItemType

        ' Is it the pager? 
        If (itemType = ListItemType.Pager) Then
            ' Extract the Pager 
            Dim pager As TableCell = CType(e.Item.Controls(0), TableCell)

            ' Add Cell to Row to Hold Row Count Label 
            Dim newcell As TableCell = New TableCell
            newcell.ColumnSpan = 1
            newcell.HorizontalAlign = HorizontalAlign.Left
            newcell.Style("border-color") = pager.Style("border-color") ' Set Border so the Pager Row looks seamless 

            ' Add Label Indicating Row Count 
            Dim lblNumRecords As Label = New Label
            lblNumRecords.ID = "lblNumRecords"
            newcell.Controls.Add(lblNumRecords)

            ' Add Table Cell to Pager 
            e.Item.Controls.AddAt(0, newcell)

            ' Subtract from Colspan of Original Pager to Account for New Row 
            pager.ColumnSpan = pager.ColumnSpan - 1
        End If
    End Sub

    Private Sub DataGrid1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.PreRender
        Try
            'Find the Labels and Set to the Record Count 
            'This Line Sets the Label at the Top. Remove if only using the Pager at the bottom. 
             CType(DataGrid1.Controls(0).Controls(0).FindControl("lblNumRecords"), Label).Text = CType(DataGrid1.DataSource, DataView).Count.ToString() + " records found"

            'This Line Sets the Label at the Bottom. Remove if only using the Pager at the top. 

                   CType(DataGrid1.Controls(0).Controls(DataGrid1.Controls).Controls.Count - 1).FindControl("lblNumRecords"), Label).Text = CType(DataGrid1.DataSource, DataView).Count.ToString() + " records found"
        Catch
        End Try

    End Sub
Previous
Reply
Map
View

Click here to load this message in the networking platform