Re: Подпись страниц в DataGrid
От: mogadanez Чехия  
Дата: 19.07.04 14:02
Оценка:
Здравствуйте, gas, Вы писали:

gas>Есть DataGrid, надо что бы его страницы подписывались цифрами, а переход на следующие страницы показывался не стандартными "..." а "Next"/"Previous"


gas>Если делать PagerStyle.Mode="NumericPages", то поля NextPageText и PrevPageText просто игнорируется, при PagerStyle.Mode="NextPrev" не выводятся номера...


gas>Что можно сделать?


"переписать" пейджер например в ItemCreate:
примерно так:

Protected Sub ItemCreate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdValues.ItemCreated
      Dim i As Integer
      Dim l_btnPagerButton As LinkButton
      Dim iBlocksCount As Integer
      Dim iCurrentBlock As Integer
      Dim iPageControlIndex As Integer
      If e.Item.ItemType = ListItemType.Pager Then
        iBlocksCount = Math.Floor(grdValues.PageCount / 10) + IIf((grdValues.PageCount Mod 10) > 0, 1, 0)
        iCurrentBlock = Math.Floor((grdValues.CurrentPageIndex + 1) / 10) + IIf(((grdValues.CurrentPageIndex + 1) Mod 10) > 0, 1, 0)
        For i = 0 To e.Item.Cells(0).Controls.Count - 1
          Try
            CType(e.Item.Cells(0).Controls(i), LiteralControl).Text = " | "
          Catch
          End Try
          Try
            l_btnPagerButton = CType(e.Item.Cells(0).Controls(i), LinkButton)
            If l_btnPagerButton.Text = "..." Then
              If Convert.ToInt32(l_btnPagerButton.CommandArgument) < (grdValues.CurrentPageIndex + 1) Then
                l_btnPagerButton.Text = "<<"
              Else
                l_btnPagerButton.Text = ">>"
              End If
            End If
          Catch
          End Try
        Next
        If grdValues.CurrentPageIndex > 0 Then
          l_btnPagerButton = New LinkButton()
          l_btnPagerButton.CommandName = "Page"
          l_btnPagerButton.Text = "<"
          l_btnPagerButton.CausesValidation = False
          l_btnPagerButton.CommandArgument = grdValues.CurrentPageIndex
          iPageControlIndex = IIf((grdValues.CurrentPageIndex + 1) > 10, 1, 0)
          e.Item.Cells(0).Controls.AddAt(iPageControlIndex, l_btnPagerButton)
          e.Item.Cells(0).Controls.AddAt(1, New LiteralControl(" | "))
        End If
        If grdValues.CurrentPageIndex < (grdValues.PageCount - 1) Then
          l_btnPagerButton = New LinkButton()
          l_btnPagerButton.CommandName = "Page"
          l_btnPagerButton.Text = ">"
          l_btnPagerButton.CausesValidation = False
          l_btnPagerButton.CommandArgument = grdValues.CurrentPageIndex + 2
          If (iCurrentBlock < iBlocksCount) Then
            e.Item.Cells(0).Controls.AddAt(e.Item.Cells(0).Controls.Count - 1, l_btnPagerButton)
            e.Item.Cells(0).Controls.AddAt(e.Item.Cells(0).Controls.Count - 1, New LiteralControl(" | "))
          Else
            e.Item.Cells(0).Controls.Add(New LiteralControl(" | "))
            e.Item.Cells(0).Controls.Add(l_btnPagerButton)
          End If

        End If
        e.Item.Cells(0).Controls.AddAt(0, New LiteralControl("Перейти на страницу: "))
      End If
    End Sub
... << RSDN@Home 1.1.3 stable >>
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.