Datagrid and Pagging

R

Ricardo Manuel

Hi,
I'm using a Datagrid that I fill with a Dataset but
when I configure the paging with the Navigation Buttons I
can't put them working, I've tried both methods (Next,
Previous and Page Numbers) when I click on the Next link
of the navigation buttons I see on status bar the
folowing code -> Javascript:__doPostBack('Datagrid1$_ctl9
$_ctl1','') but nothing happens on Datagrid.

I've configured the datagrid for 5 rows and Dataset
returns about 20 rows.

Thanks in advance
Ric
..
 
M

Marina

You have to handle the page changing event in the datagrid, and write your
own code to advance to the next page.
 
S

Scott M.

Just because you've changed the DataGrid's interface to support or "Enable"
paging, doesn't mean that the functionality is automatic, it just means that
you'll have the buttons (or hyperlinks) that a user can click. You still
must write the code for the PageIndexChanged event that fires when someone
clicks the paging button (or hyperlink).

See code below (by the way the same concept is true when you enable sorting
in the DataGrid - - I've included that code as well):

Private Sub dg_PageIndexChanged(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
dg.PageIndexChanged
dg.CurrentPageIndex = e.NewPageIndex
dg.DataBind()
End Sub

Private Sub dg_SortCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles
dg.SortCommand
Dim dv As New DataView(dsCusts.Tables(0))
dv.Sort = e.SortExpression
dg.DataSource = dv
dg.DataBind()
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top