分页时使当前页码变色

      ''以下代碼放在DataGrid的ItemCreated事件中即可
       Dim i As Integer
        If e.Item.ItemType = ListItemType.Pager Then
            Dim _labPage As Label
            Dim pager As TableCell
            pager = CType(e.Item.Controls(0), TableCell)
            For i = 0 To pager.Controls.Count - 1
                Dim obj As Control
                obj = pager.Controls(i)
                Try
                    _labPage = CType(obj, Label)
                    _labPage.ForeColor = Color.Red
                Catch ex As Exception

                End Try
            Next
        End If

你可能感兴趣的:(分页)