0

I am getting nullPointerException at this point and this is my code:

int reservationID = Convert.ToInt32(dgvReservation.Rows[a].Cells[0].Value.ToString());

public void GetResrervationTables()
        {
            ManagerTableReservation mgrTableReservation = new ManagerTableReservation();

            for (int a = 0; a < dgvMenuItems.Rows.Count; a++)
            {
                int reservationID = Convert.ToInt32(dgvReservation.Rows[a].Cells[0].Value.ToString());

                List<int> listOfReservationTables = mgrTableReservation.GetReservationTablesByReservationID(reservationID);

                              
                    string tables = "";

                    foreach (int t in listOfReservationTables)
                    {
                        int count = listOfReservationTables.Count;

                         tables = tables + "," + t.ToString();
                        

                        count--;
                    }

                    dgvReservation.Rows[a].Cells[7].Value = tables; 
            }
2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by xanawa
0

Make sure that dgvReservartion.Rows[a].IsNewRow isn't true. If your data grid view allows users to enter new rows directly, that last row with the * tends to be problematic.

0

Make sure that dgvReservartion.Rows[a].IsNewRow isn't true. If your data grid view allows users to enter new rows directly, that last row with the * tends to be problematic.

ok that problem is resolved but i have anothe rproblem the string is not displaying in d cell

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.