我想动态生成一个table。如下:
<td height= "22 "> <table width= "100% " border= "0 " cellspacing= "0 " cellpadding= "0 ">
<tr>
<td height= "22 " align= "center "> <img src= "../images/DD.gif " width= "9 " height= "9 "> </td>
<td height= "22 "> <a href= "Modul1.aspx " target= "main "> 模块一 </a> </td>
</tr>
<tr>
<td height= "22 " align= "center "> <img src= "../images/DD.gif " width= "9 " height= "9 "> </td>
<td height= "22 "> <a href= "Modul1.aspx " target= "main "> 模块二 </a> </td>
</tr>
<tr>
<td height= "22 " align= "center "> <img src= "../images/DD.gif " width= "9 " height= "9 "> </td>
<td height= "22 "> <a href= "Modul1.aspx " target= "main "> 模块三 </a> </td>
</tr>
<tr>
<td height= "22 " align= "center "> <img src= "../images/DD.gif " width= "9 " height= "9 "> </td>
<td height= "22 "> <a href= "Modul1.aspx " target= "main "> 模块四 </a> </td>
</tr>
</table> </td>
在这些页面中,我要做的事情是:
1:动态生成这些table。
2:在用户单击《模块X》的时候,连接到另外一个页面中。在连接到另外一个页面前,要检测用户单击的是《模块一》还是《模块几》,然后根据用户单击的模块添加不同的session。这个session是一个名字,这不过不同的值。
请问,我要做如上两个如何做?
------解决方案--------------------1 直接输出html
2 js创建table
------解决方案--------------------3 web控件table操作
------解决方案--------------------for (int i = 0; i <模块数 ; i++)
{
TableRow row = new TableRow();
for (int j = 0; j < 列数; j++)
{
TableCell cell = new TableCell();
cell.Text = " <a href=\ "目标页.aspx?参数= " + 模块数[i] + "\ "> 查看详细 </a> ";
}
row.Cells.Add(cell);
}
mytable.Rows.Add(row);//mytable为你的table控件id
------解决方案-------------------- <td height= "22 "> <table width= "100% " border= "0 &