mohammed shamsheer

mohammed shamsheer

  • 1.2k
  • 394
  • 139.6k

object Reference is set to instance of an object

Dec 5 2014 5:18 AM

 for (int j = 0; j < dgvcheckin.Rows.Count; j++)
                               {
                                   if (Convert.ToBoolean(dgvcheckin.Rows[j].Cells["RoomNo"].Value) == null)
                                   {
                                       dgvcheckin.Rows.Remove(dgvcheckin.CurrentRow);
                                   }
                               }

                               int NumberofRooms=1;
                               
                               for (int j = 0; j < dgvcheckin.Rows.Count;j++ )
                               {
                                  

                                   if (dgvcheckin.Rows[j].Cells["RoomNo"].Value.ToString() != "" || dgvcheckin.Rows[j].Cells["RoomNo"].Value != null)
                                   {
                                   
                                       NumberofRooms=+NumberofRooms;
                                   }
                               }


This is my code when compiler check the datagridview room cell it give back null then it going to exception and skip the remaining the code any body have any idea....



Answers (7)