ASP.NET动态增加或减少TABLE列和行 控件实例
2009-04-13 16:10
471 查看
ASP.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);
}
}}
本文来自: IT知道网(http://www.itwis.com) 详细出处参考:http://www.itwis.com/html/net/aspnet/20080326/1149.html
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);
}
}}
本文来自: IT知道网(http://www.itwis.com) 详细出处参考:http://www.itwis.com/html/net/aspnet/20080326/1149.html
相关文章推荐
- asp.net表格控件Table(实例动态增加表格)
- Asp.Net Table控件动态生成表格操作实例(代码调试通过)
- ASP.NET中实现动态增加或减少TABLE列和行
- ASP.NET 页面中动态增加的控件、添加事件第1/2页
- 【转】ASP.NET中服务器控件Table动态生成表格及其属性介绍
- ASP.NET中服务器控件Table动态生成表格及其属性介绍
- ASP.NET动态新增/减少控件的实现(C#)
- asp.net动态增加服务器端控件并提交表单
- ASP.NET页面中动态增加的控件、添加事件
- asp.net 动态管理(增加、删除、读取)控件
- ASP.NET给Table动态添加删除行,并且得到控件的值
- ASP.NET动态增加HTML元素的方法实例小结
- ASP.NET页面中动态增加的控件、添加事件
- ASP.NET 页面中动态增加的控件、添加事件第1/2页
- ASP.NET动态增加HTML元素的方法实例小结
- asp.net 动态删除、增加上传控件——{超好}
- ASP.NET动态新增/减少控件的实现(VB)
- Asp.net 2.0 自定义控件开发专题讲解[为用户控件增加DataSource属性, 能够自动识别不同数据源](示例代码下载)
- Asp.net 2.0 自定义控件开发专题讲解[为用户控件增加DataSource属性, 能够自动识别不同数据源](示例代码下载)
- asp.net mvc动态生成file控件批量上传文件