Paging in a dg - current row?

Discussion in 'ASP .Net Datagrid Control' started by Marc Miller, Nov 14, 2003.

  1. Marc Miller

    Marc Miller Guest

    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
    Marc Miller, Nov 14, 2003
    #1
    1. Advertising

  2. Marc Miller

    MSFT Guest

    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.)
    MSFT, Nov 17, 2003
    #2
    1. Advertising

  3. Marc Miller

    IK Guest

    What is the PostionInPage variable? Where does it come from?
    Thanks
    IK

    "MSFT" <> wrote in message
    news:bS%...
    > 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.)
    >
    IK, Nov 25, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    DataSet paging vs Datareader paging

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Oct 8, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    10,659
    Scott Allen
    Oct 8, 2004
  2. wh1974
    Replies:
    0
    Views:
    2,419
    wh1974
    Jan 12, 2005
  3. Red
    Replies:
    1
    Views:
    706
  4. D
    Replies:
    0
    Views:
    198
  5. Andrus

    Insert new row before current row

    Andrus, Jun 29, 2003, in forum: Javascript
    Replies:
    0
    Views:
    100
    Andrus
    Jun 29, 2003
Loading...

Share This Page