Paging in a dg - current row?

M

Marc Miller

Hello,

I have a datagrid in which I change the color of the row, based on a value
in a particular column.
My problem is that I need to know the current row number in the data set
after I page from the
first page.

I see the error in my ways here, since I am constantly referring to rows 0
thru 4. What can I
use as a reference for introw in the rowcolor procedure?

Thanks,
Marc Miller
Dim i As Integer

For i = 0 To Me.dgPODetails.PageSize - 1 ' Page size here is 5

Me.rowcolor(i)

Next i

---------------------------------------------------------------------
Private Sub rowcolor(ByVal intRow As Integer)

Dim IsClosed As String

IsClosed = objDs.Tables(0).Rows(intRow).Item("closed_code")

If IsClosed = "CLOSED" Then

Me.dgPODetails.Items(intRow).ForeColor = Color.FromName("Red")

etc, etc................................

END SUB
 
M

MSFT

Hi Marc,

You can get the page number in datagrid's PageIndexChanged event:

Public Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
DataGrid2.PageIndexChanged

To get the row number, you can get from:

e.NewPageIndex * DataGrid2.PageSize+PostionInPage

For a sample on ASp.NET DataGrid Paging, you can refer to:

http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q318131

Hope this help,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top