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; 
            }

Recommended Answers

All 2 Replies

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.