Hi Dman100,
Try the following
Aspx page
Dates of Sunday in Current Year |
---|
|
Code Behind (cs Page)
protected void Page_Load(object sender, EventArgs e)
{
DateTime dtCurrentDate;
dtCurrentDate = DateTime.Now;
DateTime dtStartDate = Convert.ToDateTime("01/01/
" + dtCurrentDate.Year.ToStrin
g());
DateTime dtEndDate = Convert.ToDateTime("01/01/
" + Convert.ToString(dtCurrent
Date.Year + 1)).AddDays(-1);
DataTable objDataTable = new DataTable();
objDataTable.Columns.Add("
SunDate");
DataRow objDataRow;
for (DateTime i = dtStartDate; i <= dtEndDate; i = i.AddDays(1))
{
if (i.DayOfWeek == DayOfWeek.Sunday)
{
objDataRow = objDataTable.NewRow();
objDataRow["SunDate"] = i.ToShortDateString();
objDataTable.Rows.Add(objD
ataRow);
i = i.AddDays(6);
}
}
SundayRepeater.DataSource = objDataTable;
SundayRepeater.DataBind();
}