locked
How to check if a datarow exists by row index? RRS feed

  • Question

  • User1623409651 posted

    Hi all,

    Running the below code is giving the following error:

    "System.IndexOutOfRangeException: 'There is no row at position 33.

    int RowNumber = 33;
    if (dTable.Rows[RowNumber] == null)
    {
    Response.Write("row does not exists");
    return;
    }

    Regards,

    Wednesday, December 5, 2018 11:06 AM

All replies

  • User-821857111 posted

    if(dTable.Rows.Count - 1 < RowNumber )
    {
        //row doesn't exist
    }

    Wednesday, December 5, 2018 11:22 AM