如题:如何更改datagrid的分页页码形式?也就是说一般情况下:的分页数字是1 2 3 4……等
      如何更改成:[1] [2] [3] [4]……

解决方案 »

  1.   

    自定义分页的代码:
    Sub binding()
            Dim con1 As New conclass.conclass
            con1.con1.Open()
            Dim sql As String
            sql = "select id, name,title,hfdateendtime,hits from xx where hf= '是'   order by hfdateendtime desc"
            Dim adapter1 As New OleDbDataAdapter(sql, con1.con1)
            Dim dataset11 As New DataSet
            adapter1.Fill(dataset11, "xx")
            Label3.Text = dataset11.Tables("xx").Rows.Count.ToString
            total.Text = dataset11.Tables("xx").Rows.Count.ToString
            Dim pads As New PagedDataSource
            pads.DataSource = dataset11.Tables("xx").DefaultView
            pads.AllowPaging = True
            pads.PageSize = 20
            pagetotal1.Text = pads.PageCount.ToString()
            label2.Text = pads.PageCount.ToString
            Dim currentpage As Integer
            If Not Request.QueryString("page") Is Nothing Then
                currentpage = Convert.ToInt32(Request.QueryString("page"))
            Else
                currentpage = 1
            End If
            pads.CurrentPageIndex = currentpage - 1
            Label1.Text = currentpage.ToString
            pageno.Text = currentpage.ToString
            If Not pads.IsFirstPage Then
                up.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(currentpage - 1)
                hyperlink2.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(currentpage - 1)
                first.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=1"
            End If
            If Not pads.IsLastPage Then
                down.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(currentpage + 1)
                hyperlink3.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(currentpage + 1)
                last.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(pads.PageCount)
                hyperlink4.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(pads.PageCount)
            End If
            If pads.IsFirstPage Then
                first.NavigateUrl = ""
                hyperlink1.NavigateUrl = ""
            End If
            If pads.IsLastPage Then
                last.NavigateUrl = ""
                hyperlink4.NavigateUrl = ""
            End If
            DataList1.DataSource = pads
            DataList1.DataBind()
        End Sub
      

  2.   

    PagerStyle-CssClass   通过CSS应该可以吧