Click here to Skip to main content
15,921,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Note it is windows application.


I tried the code but it is not working.

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)
{
if (DayOfWeek == DayOfWeek.Sunday)
{
DGVCalendar.Rows[row].Cells[1].Value = false;
}

DGVCalendar.Rows[row].Cells[1].Value = dt1.ToString("dd-MM-yy");
DGVCalendar.Rows[row].Cells[0].Value = true; //All checkbox Checked Defaulty
dt1 = dt1.AddDays(1);
row++;
}

}

In the above i am validating sunday date disable in datagridview.

for that i written the code.

if (DayOfWeek == DayOfWeek.Sunday)
{
DGVCalendar.Rows[row].Cells[1].Value = false;
}


The above code is not working,what is problem in my above code.

when i run shows the error as follows;
System.DayOfWeek' is a 'type' but is used like a variable

what can i do.
please help me.

Regards,
Narasiman P.

Note It is windows application
Posted

1 solution

hii buddy

there need is just minute change...like
you have just put the object of dateTime datatype variablewith DayofWeek...

C#
if (dt1.DayOfWeek == DayOfWeek.Sunday)
{
DGVCalendar.Rows[row].Cells[1].Value = false;
}

happy to help....
 
Share this answer
 

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