Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My code:

C#
private void dgtaskdetails_CellLeave_2(object sender, DataGridViewCellEventArgs e)
       {
            
           if (dgtaskdetails.Columns[e.ColumnIndex].Name == "End-Date")
           {
         
                   var returnDate = Convert.ToDateTime(dataGridView1.Rows[e.RowIndex].Cells["End-Date"].Value);
                   var borrowDate = Convert.ToDateTime(dataGridView1.Rows[e.RowIndex].Cells["Start-Date"].Value);
                   if (returnDate > borrowDate)
                   {
                        
                       MessageBox.Show(""From Date" cannot be greater than "To Date"");
                       
                   }


           }

error:
SQL
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Posted
Comments
Jeet Gupta 13-Jan-15 0:33am    
from which position this error is coming. debugg the code from which position error occured.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900