日期:2014-05-17 浏览次数:20411 次
using System;
using System.Data;
/// <summary>
/// 我的365天 by jon
/// <remarks>仿新浪的轻微博http://qing.weibo.com $$ http://qing.weibo.com/tag/365 365模块链接</remarks>
/// </summary>
public partial class Calender_test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ViewState["Data"] = DateTime.Now;
Bind();
}
}
//定义一个二维数组
string[,] week = { { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }, { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" } };
/// <summary>
/// 每个月的第一天前面的空格个数标记
/// </summary>
public int golb_tag = 0;
/// <summary>
/// 根据当前的ViewState时间得到日历
/// </summary>
protected void Bind()
{
DateTime data = (DateTime)ViewState["Data"];
int year = data.Year;
int month = data.Month;
int days = DateTime.DaysInMonth(year, month);//获取指定 year 中 month 的天数
DataTable daysdt = new DataTable();//实例一个表格等待填充
string[] col = { "day", "Data", "week", "class" };
for (int i = 0; i < col.Length; i++)
{
DataColumn dc = new DataColumn();
dc.ColumnName = col[i];
daysdt.Columns.Add(dc);
}
int tag = 0;//星期标记
DateTime start = Convert.ToDateTime(year.ToString() + "-" + month.ToString() + "-" + "1");//月份第一天
for (int i = 0; i < 7; i++)//得到在1号之前的置空个数
&nb