using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
HtmlTable table = new HtmlTable();
for (int i = 0; i < 5; i++)
{
HtmlTableRow row = new HtmlTableRow();
for (int j = 0; j <5; j++)
{
HtmlTableCell cell = new HtmlTableCell();
Button btn = new Button();
btn.Text = i.ToString() + j.ToString();
cell.Controls.Add(btn);
//cell.InnerHtml = string.Format("i:{0} j:{1}",i,j);
row.Cells.Add(cell);
}
table.Rows.Add(row);
}
this.Panel1.Controls.Add(table);
}
protected void Button2_Click(object sender, EventArgs e)
{
Table t = new Table();
for (int i = 0; i < 2; i++)
{
TableRow row = new TableRow();
for (int j = 0; j < 2; j++)
{
TableCell cell = new TableCell();
Button btn = new Button();
btn.Text = i.ToString() + j.ToString();
cell.Controls.Add(btn);
row.Cells.Add(cell);
}
t.Rows.Add(row);
}
this.Panel1.Controls.Add(t);
}
protected void Button3_Click(object sender, EventArgs e)
{
DataTable da = new DataTable();
DataColumn cl = new DataColumn();
cl.ColumnName = "id";
cl.DataType = typeof(int);
cl.AllowDBNull = false;
cl.AutoIncrement = true;
cl.AutoIncrementSeed = 1;
cl.AutoIncrementStep = 1;
da.Columns.Add(cl);
cl = new DataColumn();
cl.ColumnName = "name";
cl.DataType = typeof(int);
cl.AllowDBNull = false;
da.Columns.Add(cl);
DataRow ro = da.NewRow();
ro["name"]="zhang san ";
da.Rows.Add(ro);
this.DropDownList1.DataSource = da;
this.DropDownList1.DataTextField = "name";
this.DropDownList1.DataValueField = "id";
this.DropDownList1.DataBind();
}
}