System.Web.UI.Control转换为System.Windows.Form

时间:2014-09-28 14:40:54

标签: vb.net gridview

我有以下代码,它工作正常,直到现在并且突然出现此错误(' System.Web.UI.Control'无法转换为'系统。 Windows.Forms.Label )  在演示之前弹出。快速帮助将受到高度赞赏。感谢

Private Sub InitialiseGridViewPagerRow(ByVal gridView As GridView)
        Dim gridViewRow As GridViewRow = gridView.BottomPagerRow
        If (Not (gridViewRow) Is Nothing) Then
            If (gridView.PageIndex = 0) Then


                Dim firstPageImageButton As LinkButton = CType(gridViewRow.FindControl(gridView.ID & "First"), LinkButton)
                Dim previousPageImageButton As LinkButton = CType(gridViewRow.FindControl(gridView.ID & "Previous"), LinkButton)
                If ((Not (firstPageImageButton) Is Nothing) AndAlso (Not (previousPageImageButton) Is Nothing)) Then
                    firstPageImageButton.Enabled = False
                    firstPageImageButton.CssClass = "firstdisabled"
                    previousPageImageButton.Enabled = False
                    previousPageImageButton.CssClass = "previousdisabled"
                End If
            ElseIf ((gridView.PageIndex + 1) = gridView.PageCount) Then

                Dim lastPageImageButton As LinkButton = CType(gridViewRow.FindControl(gridView.ID & "Last"), LinkButton)
                Dim nextPageImageButton As LinkButton = CType(gridViewRow.FindControl(gridView.ID & "Next"), LinkButton)
                If ((Not (lastPageImageButton) Is Nothing) AndAlso (Not (nextPageImageButton) Is Nothing)) Then
                    lastPageImageButton.Enabled = False
                    lastPageImageButton.CssClass = "lastdisabled"
                    nextPageImageButton.Enabled = False
                    nextPageImageButton.CssClass = "nextdisabled"
                End If
            Else

                Dim firstPageImageButton As LinkButton = CType(gridViewRow.FindControl(gridView.ID & "First"), LinkButton)
                Dim previousPageImageButton As LinkButton = CType(gridViewRow.FindControl(gridView.ID & "Previous"), LinkButton)
                Dim lastPageImageButton As LinkButton = CType(gridViewRow.FindControl(gridView.ID & "Last"), LinkButton)
                Dim nextPageImageButton As LinkButton = CType(gridViewRow.FindControl(gridView.ID & "Next"), LinkButton)

                If ((Not (firstPageImageButton) Is Nothing) AndAlso ((Not (lastPageImageButton) Is Nothing) AndAlso ((Not (previousPageImageButton) Is Nothing) AndAlso (Not (nextPageImageButton) Is Nothing)))) Then
                    firstPageImageButton.Enabled = True
                    lastPageImageButton.Enabled = True
                    nextPageImageButton.Enabled = True
                    previousPageImageButton.Enabled = True

                End If
            End If

            Dim pageNumberDropDownList As DropDownList = CType(gridViewRow.FindControl(gridView.ID & "ddlPgNo"), DropDownList)
'Error is only on the following line
            Dim pageCountLabel As System.Web.UI.WebControls.Label = CType(gridViewRow.FindControl(gridView.ID & "PgCnt"), Label)

            If ((Not (pageNumberDropDownList) Is Nothing) AndAlso (Not (pageCountLabel) Is Nothing)) Then
                Dim i As Integer = 0
                Do While (i < gridView.PageCount)
                    Dim page As Integer = (i + 1)
                    pageNumberDropDownList.Items.Add(New ListItem(page.ToString, i.ToString))
                    i = (i + 1)
                Loop
                pageNumberDropDownList.SelectedIndex = gridView.PageIndex
                pageCountLabel.Text = gridView.PageCount.ToString

            End If
        End If
    End Sub

1 个答案:

答案 0 :(得分:0)

通过评论

解决了问题
Imports System.Windows.Forms