.NET2005,怎么用代码创建表格,而且把数据写到创建的表格里。
解决方案 »
- 急!急!在哪能找到project Dependencies 选项卡,我怎么找不到啊?
- 在线等,急 DataList 绑定oracle 显示数据问题
- 关于如何控制HTML控件显示的问题,请大家帮忙!
- 弹出的模态页面在有控件的AutoPostBack为True时,又要生成一个新的非模态页面
- 我想在 asp.net网页 上,做一个 监视程序,能够监视网页上的文件(打开,修改,删除)
- 如何通过POST来传递一段XML文件呢?
- 这样的日历问题!
- gridview数据绑定,格式化数据问题
- 文本框中输入<...>提示脚本攻击错误...怎么解决
- 你们做报表是怎么分页的?
- 确认一下winform网络编程和asp.net的区别
- GridView 添加数据 一次提交问题
这样写就行了
Radi rad = new Radi();
rad.RepeatDirection = RepeatDirection.Horizontal;
TextBox box = new TextBox();
box.TextMode = TextBoxMode.Password;
rad.Items.Add("男"); rad.Items.Add("女");
cob com = new cob();
com.Items.Add("本科");com.Items.Add("大专");com.Items.Add("硕士");
this.Table1.Rows[0].Cells[1].Controls.Add(new TextBox());
this.Table1.Rows[0].Cells[3].Controls.Add(box);
this.Table1.Rows[1].Cells[1].Controls.Add(new TextBox());
this.Table1.Rows[1].Cells[3].Controls.Add(rad);
this.Table1.Rows[2].Cells[1].Controls.Add(com);
this.Table1.Rows[2].Cells[3].Controls.Add(new TextBox());
<style type="text/css">
.tabStyle { color: #333; background-color:Maroon;}
.tabStyle td { margin: 1px; padding: 2px; background-color:White; }
</style>protected void Page_Load(object sender, EventArgs e)
{
Table tb = new Table();
using (SqlConnection conn = new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["连接字符串"].ConnectionString))
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "select 字段名1, 字段名2 from 表名"; conn.Open();
SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
while (reader.Read())
{
TableRow row = new TableRow(); TableCell cell = new TableCell(); cell.Text = reader["字段名1"].ToString();
row.Cells.Add(cell); cell = new TableCell();
cell.Text = reader["字段名2"].ToString();
row.Cells.Add(cell); tb.Rows.Add(row);
}
}
tb.CssClass = "tabStyle";
this.Controls.Add(tb);}