Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
I want selected month date want to display in datagridview using c sharp.
 
My Code as follows;
 
private void Faculty_Available_Calendar_DateChanged(object sender, DateRangeEventArgs e)
        {
              
             DGVCalendar.Rows.Clear();
             DateTime dt1 = Faculty_Available_Calendar.SelectionStart;
             dt1 = new DateTime(dt1.Year, dt1.Month, 1);
             DateTime dt2 = dt1.AddMonths(1);
             int numDays = (dt2 - dt1).Days;
             if (DGVCalendar.RowCount < numDays)
             {
                DGVCalendar.RowCount = numDays;
             }
            int row = 0;
            while (dt1 < dt2)
            {
                 DGVCalendar.Rows[row].Cells[0].Value = dt1.ToString("dd-MM-yy");
                 dt1 = dt1.AddDays(1);
                 row++;
            }
         
        }
 
In datagridview ouput as follows; (when i select march month means that month all dates want to display in datagridview)
 
Select Month(Name) column Name)
 
Checkbox 1/3/2013 to 31/3/2013 (dsiplay in datagridview)
 

When i select the month in (Month Calendar Control) in run mode,Error shows as follows;
 
string was not recognized as valid Boolean.'
 
This error happen when i add Checkbox in datagridview.
 
suppose i remove the Checkbox in datagridview, Correctly working why?
 
I want to add checkbox, so that select the date and save in database.
Posted 22-Feb-13 3:33am
Edited 22-Feb-13 4:00am
CHill6086.3K
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You've added the check box to the left of the date so it is actually in Cells[0].
 
If you remove the CheckBox then the date again becomes Cells[0].
 
You have a choice now ...
Either put the CheckBox column to the right of the date (Cells[1])
OR
change the line
DGVCalendar.Rows[row].Cells[0].Value
to be
DGVCalendar.Rows[row].Cells[1].Value
 
Better yet, define some const values e.g. const int DateColumn = 0 and use
DGVCalendar.Rows[row].Cells[DateColumn].Value 
  Permalink  

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

  Print Answers RSS
0 Maciej Los 495
1 Sergey Alexandrovich Kryukov 469
2 OriginalGriff 360
3 Sascha Lefévre 255
4 Abhinav S 250
0 Sergey Alexandrovich Kryukov 10,102
1 OriginalGriff 9,495
2 Peter Leow 5,241
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 3,076


Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 22 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100