我想把表格生成像下面那样的 <table style="width:200px; height:200px; border-color:Red; border-collapse:collapse;">
<tr>
<td colspan="2" rowspan="2"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td rowspan="2"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td rowspan="2"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
下面是我.CS文件中生成的代码 String[] HH = { "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "01", "02", "03", "04", "05", "06", "07" };
String[] SS = { "00", "15", "30", "45" }; String[] Week = { "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日" };
protected void ShowTable()
{
TableRow tr;
TableCell tc; int Count_Row_Sum = HH.Length * SS.Length; //获得行数
int Count_Col_Sum = Week.Length + 1; //获得列数 for (int Row_Count = 0; Row_Count < Count_Row_Sum + 1; Row_Count++)
{
tr = new TableRow();
//行数
#region if
if (Row_Count == 0)
{
//第一行标题
for (int Col_Count = 0; Col_Count < Count_Col_Sum; Col_Count++)
{
//列数
tc = new TableCell();
if (Col_Count >= 1)
{
//第一列
tc.Text = Week[Col_Count - 1];
}
else if (Col_Count == 0)
{
//第一行,第一列,跨2列4行
tc.ColumnSpan = 2;
}
tc.BackColor = Color.Brown;
tr.Cells.Add(tc);
}
}
else
{
#endregion
int c = (Row_Count - 1) / 4; //获取小时的数组的编号
int x = (Row_Count - 1) % 4; //获取分钟的数组的编号
//内容
if (x == 0)
{
for (int Col_Count = 0; Col_Count < Count_Col_Sum + 1; Col_Count++)
{
tc = new TableCell();
if (Col_Count == 0)
{
//第一列跨4行
tc.RowSpan = 4;
tc.Text = HH[c];
}
else if (Col_Count == 1)
{ //第二列不跨行
tc.Text = SS[x];
}
tr.Cells.Add(tc);
}
}
else
{
for (int Col_Count = 0; Col_Count < Count_Col_Sum; Col_Count++)
{
tc = new TableCell();
tc.Text = Row_Count + "-" + Col_Count; if (Col_Count == 0)
{
//第二列不跨行
tc.Text = SS[x];
} if (Row_Count % 2 == 0)
{
tr.BackColor = Color.Crimson; }
else
{
tr.BackColor = Color.DarkViolet;
}
tr.Cells.Add(tc);
}
}
}
list.Controls.Add(tr);
}
}总是实现不了上面的哪个格式,望高手帮我看下是哪里错了
<tr>
<td colspan="2" rowspan="2"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td rowspan="2"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td rowspan="2"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
下面是我.CS文件中生成的代码 String[] HH = { "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "01", "02", "03", "04", "05", "06", "07" };
String[] SS = { "00", "15", "30", "45" }; String[] Week = { "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日" };
protected void ShowTable()
{
TableRow tr;
TableCell tc; int Count_Row_Sum = HH.Length * SS.Length; //获得行数
int Count_Col_Sum = Week.Length + 1; //获得列数 for (int Row_Count = 0; Row_Count < Count_Row_Sum + 1; Row_Count++)
{
tr = new TableRow();
//行数
#region if
if (Row_Count == 0)
{
//第一行标题
for (int Col_Count = 0; Col_Count < Count_Col_Sum; Col_Count++)
{
//列数
tc = new TableCell();
if (Col_Count >= 1)
{
//第一列
tc.Text = Week[Col_Count - 1];
}
else if (Col_Count == 0)
{
//第一行,第一列,跨2列4行
tc.ColumnSpan = 2;
}
tc.BackColor = Color.Brown;
tr.Cells.Add(tc);
}
}
else
{
#endregion
int c = (Row_Count - 1) / 4; //获取小时的数组的编号
int x = (Row_Count - 1) % 4; //获取分钟的数组的编号
//内容
if (x == 0)
{
for (int Col_Count = 0; Col_Count < Count_Col_Sum + 1; Col_Count++)
{
tc = new TableCell();
if (Col_Count == 0)
{
//第一列跨4行
tc.RowSpan = 4;
tc.Text = HH[c];
}
else if (Col_Count == 1)
{ //第二列不跨行
tc.Text = SS[x];
}
tr.Cells.Add(tc);
}
}
else
{
for (int Col_Count = 0; Col_Count < Count_Col_Sum; Col_Count++)
{
tc = new TableCell();
tc.Text = Row_Count + "-" + Col_Count; if (Col_Count == 0)
{
//第二列不跨行
tc.Text = SS[x];
} if (Row_Count % 2 == 0)
{
tr.BackColor = Color.Crimson; }
else
{
tr.BackColor = Color.DarkViolet;
}
tr.Cells.Add(tc);
}
}
}
list.Controls.Add(tr);
}
}总是实现不了上面的哪个格式,望高手帮我看下是哪里错了
解决方案 »
- 想让程序产生异常后或者任何其他的错误跳转到指定的页面,该怎么办啊?
- 在此上下文中不允许使用名称 "True" 求救。。。。。
- JQUERY不能异步加载aspx页面?
- GridView问题
- 高手们,gridview1 里嵌套gridview2 的问题 求助
- 请教一个关于asp.net的问题的解决方法,急!!!
- 大家来一起讨论一下,各位都是如何用ASP.NET 设计界面的!说说各位的心得吧!
- 你用.net作了哪些系统?来者有分。
- 在这种情况下是使用INSERT语句还是用Dataset?
- 关于ASPX页面显示的时间格式问题
- 多级文件夹下页面Server.Transfe()调转问题
- marquee 滚动疑问
<%=str%>
或使用HtmlTable