ASP.net 动态table添加
来源:互联网 发布:java上传下载文件方法 编辑:程序博客网 时间:2024/05/19 05:34
HtmlTable ptable = new HtmlTable(); //创建一个表htmltable表
ptable.SkinID = "";
ptable.Style.Add("border", "1");
ptable.Style.Add("width", "100%");
ptable.Style.Add("CellPadding", "1");
ptable.Style.Add("CellSpacing", "1");
ptable.Style.Add("align", "center");
//从数据库取数据,是要赋值与htmltable控件的.
int i = 0;
for (int rowcount = 0; rowcount < 5; rowcount++)
{
HtmlTableRow row = new HtmlTableRow();
for (int cellcount = 0; cellcount < 4; cellcount++)
{
HtmlTableCell cell;
if (rowcount <= 0)
{
cell = new HtmlTableCell("td");
}
else
{
cell = new HtmlTableCell();
}
if (i < ds.Tables[0].Rows.Count)
{
LinkButton lbtn = new LinkButton();
lbtn.ID = "lbtn" + i.ToString();
int num = i++;
lbtn.Text = ds.Tables[0].Rows[num]["Mname"]==null?"":ds.Tables[0].Rows[num]["Mname"].ToString();//要显示的内容
// lbtn.PostBackUrl = "Member.aspx?id=" + ds.Tables[0].Rows[num]["pageID"] == null ? "" : ds.Tables[0].Rows[num]["pageID"].ToString();
// lbtn.ForeColor = System.Drawing.Color.SeaGreen;
// lbtn.Font.Size = FontUnit.Larger;
cell.Style.Add("border-top-width", "1px");
cell.Style.Add("border-right-width", "1px");
cell.Style.Add("border-bottom-width", "1px");
cell.Style.Add("border-left-width", "1px");
cell.Style.Add("border-top-style", "solid");
cell.Style.Add("border-right-style", "solid");
cell.Style.Add("border-bottom-style", "solid");
cell.Style.Add("border-left-style", "solid");
cell.Style.Add("border-top-color", "#CCCCCC");
cell.Style.Add("border-right-color", "#CCCCCC");
cell.Style.Add("border-bottom-color", "#CCCCCC");
cell.Style.Add("border-left-color", "#CCCCCC");
cell.Style.Add("border-left-color", "#CCCCCC");
cell.Controls.Add(lbtn);
}
row.Cells.Add(cell);
}
ptable.Rows.Add(row);
}
tdintrp.Controls.Add(ptable);//tdintrp为网页中的td元素(runat=“server”)
ptable.SkinID = "";
ptable.Style.Add("border", "1");
ptable.Style.Add("width", "100%");
ptable.Style.Add("CellPadding", "1");
ptable.Style.Add("CellSpacing", "1");
ptable.Style.Add("align", "center");
//从数据库取数据,是要赋值与htmltable控件的.
int i = 0;
for (int rowcount = 0; rowcount < 5; rowcount++)
{
HtmlTableRow row = new HtmlTableRow();
for (int cellcount = 0; cellcount < 4; cellcount++)
{
HtmlTableCell cell;
if (rowcount <= 0)
{
cell = new HtmlTableCell("td");
}
else
{
cell = new HtmlTableCell();
}
if (i < ds.Tables[0].Rows.Count)
{
LinkButton lbtn = new LinkButton();
lbtn.ID = "lbtn" + i.ToString();
int num = i++;
lbtn.Text = ds.Tables[0].Rows[num]["Mname"]==null?"":ds.Tables[0].Rows[num]["Mname"].ToString();//要显示的内容
// lbtn.PostBackUrl = "Member.aspx?id=" + ds.Tables[0].Rows[num]["pageID"] == null ? "" : ds.Tables[0].Rows[num]["pageID"].ToString();
// lbtn.ForeColor = System.Drawing.Color.SeaGreen;
// lbtn.Font.Size = FontUnit.Larger;
cell.Style.Add("border-top-width", "1px");
cell.Style.Add("border-right-width", "1px");
cell.Style.Add("border-bottom-width", "1px");
cell.Style.Add("border-left-width", "1px");
cell.Style.Add("border-top-style", "solid");
cell.Style.Add("border-right-style", "solid");
cell.Style.Add("border-bottom-style", "solid");
cell.Style.Add("border-left-style", "solid");
cell.Style.Add("border-top-color", "#CCCCCC");
cell.Style.Add("border-right-color", "#CCCCCC");
cell.Style.Add("border-bottom-color", "#CCCCCC");
cell.Style.Add("border-left-color", "#CCCCCC");
cell.Style.Add("border-left-color", "#CCCCCC");
cell.Controls.Add(lbtn);
}
row.Cells.Add(cell);
}
ptable.Rows.Add(row);
}
tdintrp.Controls.Add(ptable);//tdintrp为网页中的td元素(runat=“server”)
- ASP.net 动态table添加
- asp.net Repeater 动态添加模板列生成Table
- C#后台如何对ASP.net前台的table动态添加行?
- asp.net后台代码实现点击按钮动态添加table的一行
- asp.net TreeView动态添加
- asp.net 动态添加控件
- ASP.NET动态添加控件
- ASP.net动态生成table(原创)
- ASP.net动态生成可编辑table
- asp.net动态生成table课表
- asp.net 动态生成Table课表
- ASP.NET 的后台代码问题:动态向Table里添加按钮,却提示没有Text属性。
- asp.net 动态添加多附件上传.
- Asp.net中动态添加删除文本框
- ASP.net动态添加head标签
- asp.net 动态添加多附件上传
- ASP.net动态添加head标签
- asp.net 动态添加多附件上传.
- perl格式化输出
- 接口是什么,和抽象类有什么区别
- UVa Problem 107 - The Cat in the Hat
- Happy Thanksgiving Day!
- 什么时候用抽象类,什么时候用接口
- ASP.net 动态table添加
- 嵌入式linux中关于device的电源管理
- css---透明度
- netcat
- 红油笔
- C#数据库连接字符串
- 电子商务还能有多长的发展?
- Smarty 实现简单更改页面的背景色
- String一定差于StringBuilder吗