Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > datagirdview paging support
 

datagirdview paging support

How is use datagridviewpaging? I need document and code.How do u use paging?

Karaner  Tuesday, August 16, 2005 12:29 PM
The DataGridView does not have any support for paging. You can use Virtual mode and handle the CellValueNeeded and when the Row Index requests are larger than your "page size" (some value you determine on your own) then you can request more data. You can set the RowCount in Virtual mode based upon the expected number or rows.

-mark
DataGridView Program Manager
Microsoft
this post is provided "as-is"
Mark Rideout  Monday, August 22, 2005 5:10 PM
 Karaner wrote:

How is use datagridviewpaging? I need document and code.How do u use paging?

Tongue TiedTongue TiedTongue TiedTongue Tied
Karaner  Wednesday, August 17, 2005 8:09 AM
The DataGridView does not have any support for paging. You can use Virtual mode and handle the CellValueNeeded and when the Row Index requests are larger than your "page size" (some value you determine on your own) then you can request more data. You can set the RowCount in Virtual mode based upon the expected number or rows.

-mark
DataGridView Program Manager
Microsoft
this post is provided "as-is"
Mark Rideout  Monday, August 22, 2005 5:10 PM

Hello,

I m going to paging a gridview in Asp.net 2.0. I set AllowPaging = "true". But it automatically generates 2 page no. (1 2). How can Iedit that page numbers ?

Cheers,

Etlon

EltonSky  Friday, September 29, 2006 10:48 AM

Hello,

I m going to paging a gridview in Asp.net 2.0. I set AllowPaging = "true". But it automatically generates 2 page no. (1 2). How can Iedit that page numbers ?

Cheers,

Etlon

EltonSky  Friday, September 29, 2006 11:30 AM
EltonSky wrote:

Hello,

I m going to paging a gridview in Asp.net 2.0. I set AllowPaging = "true". But it automatically generates 2 page no. (1 2). How can Iedit that page numbers ?

Cheers,

Etlon

Hi Etlon

you can change the page navigation on the ItemCreated event of the datagrid view as following source code.

Private Sub dgView_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgView.ItemCreated

If e.Item.ItemType = ListItemType.Pager Then

Dim dg As DataGrid = CType(sender, DataGrid)

Dim Pager As TableCell = CType(e.Item.Controls(0), TableCell)

Dim cboPages As New DropDownList

cboPages.Width = Unit.Pixel(50)

cboPages.AutoPostBack = True

AddHandler cboPages.SelectedIndexChanged, AddressOf pageChange_SelectedIndexChanged

For index As Integer = 1 To 2

cboPages.Items.Add((index * 10).ToString)

Next

cboPages.SelectedValue = dg.PageSize

Dim lnkPrev As New LinkButton

Dim lnkFirst As New LinkButton

Dim lnkLast As New LinkButton

Dim lnkNext As New LinkButton

Dim lblPages As New Label

Dim lblPageCount As New Label

Dim lblRP As New Label

lnkFirst.Text = "[First]"

lnkFirst.CommandName = "Page"

lnkFirst.CommandArgument = 1

lnkPrev.Text = "< Prev Page"

lnkPrev.Style.Add("margin-left", 5)

lnkPrev.Style.Add("margin-right", 5)

lnkPrev.CommandName = "Page"

lnkPrev.CommandArgument = dg.CurrentPageIndex

lnkLast.Text = "[Last]"

lnkLast.CommandName = "Page"

lnkLast.CommandArgument = dg.PageCount().ToString

lnkNext.CommandName = "Page"

lnkNext.Text = "Next Page >"

lnkNext.Style.Add("margin-left", 5)

lnkNext.Style.Add("margin-right", 5)

lnkNext.CommandArgument = dg.CurrentPageIndex + 2

lblPages.Text = "Pages :"

lblPageCount.Text = "&nbsp;of&nbsp;" & dg.PageCount.ToString

lblRP.Text = "&nbsp; Records/Page : &nbsp;"

If dg.CurrentPageIndex > 0 Then

lnkFirst.Enabled = True

lnkPrev.Enabled = True

Else

lnkFirst.Enabled = False

lnkPrev.Enabled = False

End If

If (dg.CurrentPageIndex + 2) <= dg.PageCount Then

lnkNext.Enabled = True

lnkLast.Enabled = True

Else

lnkNext.Enabled = False

lnkLast.Enabled = False

End If

Pager.Controls.AddAt(0, lnkFirst)

Pager.Controls.AddAt(1, lnkPrev)

Pager.Controls.AddAt(2, lblPages)

Pager.Controls.Add(lblPageCount)

Pager.Controls.Add(lnkNext)

Pager.Controls.Add(lnkLast)

Pager.Controls.Add(lblRP)

Pager.Controls.Add(cboPages)

End If

End Sub

Andre Aung  Monday, October 02, 2006 2:41 AM
Hello

I like the Question and Answer. But this is like fooling others. Post the answers by looking the forum topics. Windows Forms databinding control does not have a Gridview.

Thanks
Raj
Raj - WebDev Raj  Wednesday, June 27, 2007 5:49 AM
Im looking for a way to be able to disable the paging after you have exported it to an excel spreadsheet
WarTownFinest  Thursday, July 05, 2007 3:00 PM

You can use google to search for other answers

Custom Search

More Threads

• Refresh Binding
• DataBinding Control to GUID type error
• Problem binding user control to column
• Customizing the enter key in the Datagridview control
• Binding TextBox to integer field
• Bug? DataGridView displays data entered in a TextBox before BindingSource.EndEdit() is invoked.
• Updating data with code
• error ConstraintException was unhandled
• Using the XML SQL Datatype in strongly typed DataSets
• DataGridView DataBinding ToString Interfaces Problem