首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

vb.net中怎么实现动态增加或减少TABLE列

2012-04-05 
vb.net中如何实现动态增加或减少TABLE列vb.net中如何实现动态增加或减少TABLE列[解决办法]参考://HTML 代

vb.net中如何实现动态增加或减少TABLE列
vb.net中如何实现动态增加或减少TABLE列


[解决办法]
参考:
//HTML 代码!

<asp:Table id="Table1" runat="server" BorderColor ="DeepSkyBlue" BorderStyle="Outset" BorderWidth="1px" CaptionAlign="Top"/>


//CS代码!

public partial class vs2005sample_table : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Dtable();
}
//动态生成表单
protected void Dtable()
{
int numrows = 3;
int numcells = 2;
for (int j = 0; j < numrows; j++)
{
TableRow r = new TableRow();
for (int i = 0; i < numcells; i++)
{
TableCell c = new TableCell();

// 作用与下一句作用一个,为单元格添加内容

// c.Text = string.Format("第{0}行,第{1}列", j + 1, i + 1);

c.Controls.Add(new LiteralControl("row " + j.ToString() + ", cell " + i.ToString()));
r.Cells.Add(c);
}
Table1.Rows.Add(r);
}
}

}

热点排行