/Files/Fooo/Monthday.rar 参见:Monthday.aspx.cs
如图:
DataTable dt = new DataTable();
dt.Columns.Add(new System.Data.DataColumn("Monday", typeof(System.String)));
dt.Columns.Add(new System.Data.DataColumn("Tuesday", typeof(System.String)));
dt.Columns.Add(new System.Data.DataColumn("Wednesday", typeof(System.String)));
dt.Columns.Add(new System.Data.DataColumn("Thursday", typeof(System.Decimal)));
dt.Columns.Add(new System.Data.DataColumn("Friday", typeof(System.Decimal)));
dt.Columns.Add(new System.Data.DataColumn("Saturday", typeof(System.Decimal)));
dt.Columns.Add(new System.Data.DataColumn("Sunday", typeof(System.Decimal)));
DateTime sj = DateTime.Today;
int yy = sj.Year;
int mm = Convert.ToInt32(this.TextBox2.Text.Trim()); // sj.Month;
month = mm;
int dd = sj.Day;
DateTime startDate = DateTime.Parse(yy.ToString() + "-" + mm.ToString() + "-" + "01");
int daysInFebLeap = System.DateTime.DaysInMonth(yy, mm);
DataRow dr = dt.NewRow();
for (int k = 1; k <= daysInFebLeap; k++)
{
// string dayName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(startDate.DayOfWeek).ToString();
string dayName = startDate.AddDays(k - 1).DayOfWeek.ToString();
// dr[startDate.DayOfWeek.ToString()] = k.ToString();
dr[dayName] = k.ToString();
if (dayName == "Saturday")
{
dt.Rows.Add(dr);
dr = dt.NewRow();
}
if (k == daysInFebLeap && dayName != "Saturday")
dt.Rows.Add(dr);
}
DataTable data = new DataTable();
data.Columns.Add(new System.Data.DataColumn("td", typeof(System.String)));
foreach (DataRow datadr in dt.Rows)
{
DataRow drv = data.NewRow();
//dr["Monday"]= "<td class='cursor_pointer' title='请点击选择日期' onclick='Set_Travel_Date('2009-6-28');" + " onmouseover='this.style.backgroundColor='#B8E9FB'" + " onmouseout='this.style.backgroundColor=''" + "> "<i>¥1265起</i></td>
// <td class="cursor_pointer" title="请点击选择日期" onclick="Set_Travel_Date('2009-6-29');" + " onmouseover='this.style.backgroundColor='#B8E9FB'" +"onmouseout='this.style.backgroundColor=''"+ ">" + 1111 + "<i>¥" +100 + "起</i></td>
// <td class="cursor_pointer" title="请点击选择日期" onclick="Set_Travel_Date('2009-6-30');" onmouseover="this.style.backgroundColor='#B8E9FB'" onmouseout="this.style.backgroundColor=''"><%#Eval("Tuesday")%><i>¥1265起</i></td>
// <td class="cursor_pointer" title="请点击选择日期" onclick="Set_Travel_Date('2009-6-30');" onmouseover="this.style.backgroundColor='#B8E9FB'" onmouseout="this.style.backgroundColor=''"><%#Eval("Wednesday")%> </td>
// <td class="cursor_pointer" title="请点击选择日期" onclick="Set_Travel_Date('2009-6-30');" onmouseover="this.style.backgroundColor='#B8E9FB'" onmouseout="this.style.backgroundColor=''"><%#Eval("Thursday")%> </td>
// <td class="cursor_pointer" title="请点击选择日期" onclick="Set_Travel_Date('2009-6-30');" onmouseover="this.style.backgroundColor='#B8E9FB'" onmouseout="this.style.backgroundColor=''"><%#Eval("Friday")%> </td>
// <td ><%#Eval("Saturday")%> </td>
drv["td"] = datadr["Sunday"].ToString() == "" ? "<td ></td>" : "<td class='cursor_pointer' title='请点击选择日期'" + " onclick=" + "Set_Travel_Date('2009-6-29');" + " onmouseover=" + "this.style.backgroundColor='#B8E9FB'" + " onmouseout=this.style.backgroundColor=''" + ">" + datadr["Sunday"].ToString() + "<i>¥" + 100 + "起</i></td>";
drv["td"] += datadr["Monday"].ToString() == "" ? "<td ></td>" : "<td class='cursor_pointer' title='请点击选择日期'" + " onclick=" + "Set_Travel_Date('2009-6-29');" + " onmouseover=" + "this.style.backgroundColor='#B8E9FB'" + " onmouseout=this.style.backgroundColor=''" + ">" + datadr["Monday"].ToString() + "<i>¥" + 100 + "起</i></td>";
drv["td"] += datadr["Tuesday"].ToString() == "" ? "<td ></td>" : "<td class='cursor_pointer' title='请点击选择日期'" + " onclick=" + "Set_Travel_Date('2009-6-29');" + " onmouseover=" + "this.style.backgroundColor='#B8E9FB'" + " onmouseout=this.style.backgroundColor=''" + ">" + datadr["Tuesday"].ToString() + "<i>¥" + 100 + "起</i></td>";
drv["td"] += datadr["Wednesday"].ToString() == "" ? "<td ></td>" : "<td class='cursor_pointer' title='请点击选择日期'" + " onclick=" + "Set_Travel_Date('2009-6-29');" + " onmouseover=" + "this.style.backgroundColor='#B8E9FB'" + " onmouseout=this.style.backgroundColor=''" + ">" + datadr["Wednesday"].ToString() + "<i>¥" + 100 + "起</i></td>";
drv["td"] += datadr["Thursday"].ToString() == "" ? "<td ></td>" : "<td class='cursor_pointer' title='请点击选择日期'" + " onclick=" + "Set_Travel_Date('2009-6-29');" + " onmouseover=" + "this.style.backgroundColor='#B8E9FB'" + " onmouseout=this.style.backgroundColor=''" + ">" + datadr["Thursday"].ToString() + "<i>¥" + 100 + "起</i></td>";
drv["td"] += datadr["Friday"].ToString() == "" ? "<td ></td>" : "<td class='cursor_pointer' title='请点击选择日期'" + " onclick=" + "Set_Travel_Date('2009-6-29');" + " onmouseover=" + "this.style.backgroundColor='#B8E9FB'" + " onmouseout=this.style.backgroundColor=''" + ">" + datadr["Friday"].ToString() + "<i>¥" + 100 + "起</i></td>";
drv["td"] += datadr["Saturday"].ToString() == "" ? "<td ></td>" : "<td class='cursor_pointer' title='请点击选择日期'" + " onclick=" + "Set_Travel_Date('2009-6-29');" + " onmouseover=" + "this.style.backgroundColor='#B8E9FB'" + " onmouseout=this.style.backgroundColor=''" + ">" + datadr["Saturday"].ToString() + "<i>¥" + 100 + "起</i></td>";
//dr["Monday"] = "<td >11</td><td >11</td><td >11</td><td >11</td><td >11</td><td >11</td>" + "<td class='cursor_pointer' title='请点击选择日期'" + " onclick=" + "Set_Travel_Date('2009-6-29');" + " onmouseover="+ "this.style.backgroundColor='#B8E9FB'" + " onmouseout=this.style.backgroundColor=''" + ">" + 1111 + "<i>¥" + 100 + "起</i></td>";
data.Rows.Add(drv);
}
this.Repeater2.DataSource = data;
this.Repeater2.DataBind();
dt.Columns.Add(new System.Data.DataColumn("Monday", typeof(System.String)));
dt.Columns.Add(new System.Data.DataColumn("Tuesday", typeof(System.String)));
dt.Columns.Add(new System.Data.DataColumn("Wednesday", typeof(System.String)));
dt.Columns.Add(new System.Data.DataColumn("Thursday", typeof(System.Decimal)));
dt.Columns.Add(new System.Data.DataColumn("Friday", typeof(System.Decimal)));
dt.Columns.Add(new System.Data.DataColumn("Saturday", typeof(System.Decimal)));
dt.Columns.Add(new System.Data.DataColumn("Sunday", typeof(System.Decimal)));
DateTime sj = DateTime.Today;
int yy = sj.Year;
int mm = Convert.ToInt32(this.TextBox2.Text.Trim()); // sj.Month;
month = mm;
int dd = sj.Day;
DateTime startDate = DateTime.Parse(yy.ToString() + "-" + mm.ToString() + "-" + "01");
int daysInFebLeap = System.DateTime.DaysInMonth(yy, mm);
DataRow dr = dt.NewRow();
for (int k = 1; k <= daysInFebLeap; k++)
{
// string dayName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(startDate.DayOfWeek).ToString();
string dayName = startDate.AddDays(k - 1).DayOfWeek.ToString();
// dr[startDate.DayOfWeek.ToString()] = k.ToString();
dr[dayName] = k.ToString();
if (dayName == "Saturday")
{
dt.Rows.Add(dr);
dr = dt.NewRow();
}
if (k == daysInFebLeap && dayName != "Saturday")
dt.Rows.Add(dr);
}
DataTable data = new DataTable();
data.Columns.Add(new System.Data.DataColumn("td", typeof(System.String)));
foreach (DataRow datadr in dt.Rows)
{
DataRow drv = data.NewRow();
//dr["Monday"]= "<td class='cursor_pointer' title='请点击选择日期' onclick='Set_Travel_Date('2009-6-28');" + " onmouseover='this.style.backgroundColor='#B8E9FB'" + " onmouseout='this.style.backgroundColor=''" + "> "<i>¥1265起</i></td>
// <td class="cursor_pointer" title="请点击选择日期" onclick="Set_Travel_Date('2009-6-29');" + " onmouseover='this.style.backgroundColor='#B8E9FB'" +"onmouseout='this.style.backgroundColor=''"+ ">" + 1111 + "<i>¥" +100 + "起</i></td>
// <td class="cursor_pointer" title="请点击选择日期" onclick="Set_Travel_Date('2009-6-30');" onmouseover="this.style.backgroundColor='#B8E9FB'" onmouseout="this.style.backgroundColor=''"><%#Eval("Tuesday")%><i>¥1265起</i></td>
// <td class="cursor_pointer" title="请点击选择日期" onclick="Set_Travel_Date('2009-6-30');" onmouseover="this.style.backgroundColor='#B8E9FB'" onmouseout="this.style.backgroundColor=''"><%#Eval("Wednesday")%> </td>
// <td class="cursor_pointer" title="请点击选择日期" onclick="Set_Travel_Date('2009-6-30');" onmouseover="this.style.backgroundColor='#B8E9FB'" onmouseout="this.style.backgroundColor=''"><%#Eval("Thursday")%> </td>
// <td class="cursor_pointer" title="请点击选择日期" onclick="Set_Travel_Date('2009-6-30');" onmouseover="this.style.backgroundColor='#B8E9FB'" onmouseout="this.style.backgroundColor=''"><%#Eval("Friday")%> </td>
// <td ><%#Eval("Saturday")%> </td>
drv["td"] = datadr["Sunday"].ToString() == "" ? "<td ></td>" : "<td class='cursor_pointer' title='请点击选择日期'" + " onclick=" + "Set_Travel_Date('2009-6-29');" + " onmouseover=" + "this.style.backgroundColor='#B8E9FB'" + " onmouseout=this.style.backgroundColor=''" + ">" + datadr["Sunday"].ToString() + "<i>¥" + 100 + "起</i></td>";
drv["td"] += datadr["Monday"].ToString() == "" ? "<td ></td>" : "<td class='cursor_pointer' title='请点击选择日期'" + " onclick=" + "Set_Travel_Date('2009-6-29');" + " onmouseover=" + "this.style.backgroundColor='#B8E9FB'" + " onmouseout=this.style.backgroundColor=''" + ">" + datadr["Monday"].ToString() + "<i>¥" + 100 + "起</i></td>";
drv["td"] += datadr["Tuesday"].ToString() == "" ? "<td ></td>" : "<td class='cursor_pointer' title='请点击选择日期'" + " onclick=" + "Set_Travel_Date('2009-6-29');" + " onmouseover=" + "this.style.backgroundColor='#B8E9FB'" + " onmouseout=this.style.backgroundColor=''" + ">" + datadr["Tuesday"].ToString() + "<i>¥" + 100 + "起</i></td>";
drv["td"] += datadr["Wednesday"].ToString() == "" ? "<td ></td>" : "<td class='cursor_pointer' title='请点击选择日期'" + " onclick=" + "Set_Travel_Date('2009-6-29');" + " onmouseover=" + "this.style.backgroundColor='#B8E9FB'" + " onmouseout=this.style.backgroundColor=''" + ">" + datadr["Wednesday"].ToString() + "<i>¥" + 100 + "起</i></td>";
drv["td"] += datadr["Thursday"].ToString() == "" ? "<td ></td>" : "<td class='cursor_pointer' title='请点击选择日期'" + " onclick=" + "Set_Travel_Date('2009-6-29');" + " onmouseover=" + "this.style.backgroundColor='#B8E9FB'" + " onmouseout=this.style.backgroundColor=''" + ">" + datadr["Thursday"].ToString() + "<i>¥" + 100 + "起</i></td>";
drv["td"] += datadr["Friday"].ToString() == "" ? "<td ></td>" : "<td class='cursor_pointer' title='请点击选择日期'" + " onclick=" + "Set_Travel_Date('2009-6-29');" + " onmouseover=" + "this.style.backgroundColor='#B8E9FB'" + " onmouseout=this.style.backgroundColor=''" + ">" + datadr["Friday"].ToString() + "<i>¥" + 100 + "起</i></td>";
drv["td"] += datadr["Saturday"].ToString() == "" ? "<td ></td>" : "<td class='cursor_pointer' title='请点击选择日期'" + " onclick=" + "Set_Travel_Date('2009-6-29');" + " onmouseover=" + "this.style.backgroundColor='#B8E9FB'" + " onmouseout=this.style.backgroundColor=''" + ">" + datadr["Saturday"].ToString() + "<i>¥" + 100 + "起</i></td>";
//dr["Monday"] = "<td >11</td><td >11</td><td >11</td><td >11</td><td >11</td><td >11</td>" + "<td class='cursor_pointer' title='请点击选择日期'" + " onclick=" + "Set_Travel_Date('2009-6-29');" + " onmouseover="+ "this.style.backgroundColor='#B8E9FB'" + " onmouseout=this.style.backgroundColor=''" + ">" + 1111 + "<i>¥" + 100 + "起</i></td>";
data.Rows.Add(drv);
}
this.Repeater2.DataSource = data;
this.Repeater2.DataBind();
<div class="holiday_show">
<ul class="infoshow" id="Ul2">
<a name="onlinebuy"></a>
<h5> 请选择出发日期<asp:TextBox ID="TextBox2" runat="server" OnTextChanged="TextBox1_TextChanged" Width="95px">1</asp:TextBox>月份
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" /></h5>
<ol class="moneyday1">
<table class="mon<%=month%>">
<tr class="title">
<td >星期日</td><td>星期一</td><td>星期二</td><td>星期三</td><td>星期四</td><td>星期五</td><td>星期六</td></tr>
<asp:Repeater ID="Repeater2" runat="server">
<ItemTemplate>
<tr>
<%#Eval("td")%>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</ol>
</ul>
</div>
<ul class="infoshow" id="Ul2">
<a name="onlinebuy"></a>
<h5> 请选择出发日期<asp:TextBox ID="TextBox2" runat="server" OnTextChanged="TextBox1_TextChanged" Width="95px">1</asp:TextBox>月份
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" /></h5>
<ol class="moneyday1">
<table class="mon<%=month%>">
<tr class="title">
<td >星期日</td><td>星期一</td><td>星期二</td><td>星期三</td><td>星期四</td><td>星期五</td><td>星期六</td></tr>
<asp:Repeater ID="Repeater2" runat="server">
<ItemTemplate>
<tr>
<%#Eval("td")%>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</ol>
</ul>
</div>