//ViewState 
protected void Page_Load(object sender, EventArgs e)
...{
if (!IsPostBack)
...{
ViewState["pageindex"] = "0";
pageindex(i);
}
i = int.Parse(ViewState["pageindex"].ToString());
}
//通过请求 取值
protected void Button1_Click(object sender, EventArgs e)
...{
Response.Write(Request.Form["TextBox1"].ToString());
Response.Write(Request["Text1"].ToString());
//lable 不可以
//Response.Write(Request["Label1"].ToString());
}
//table用法
protected void Page_Load(object sender, EventArgs e)
...{
Table yearTable = new Table();
yearTable.CellSpacing = 0;
yearTable.CellPadding = 0;
yearTable.Width = Unit.Percentage(100);
yearTable.Rows.Add(new TableRow());
yearTable.Rows.Add(new TableRow());
yearTable.Rows.Add(new TableRow());
yearTable.Rows[0].Cells.Add(new TableCell());
yearTable.Rows[0].Cells[0].ColumnSpan = 4;
yearTable.Rows[0].Cells[0].Text = "Actuals";
yearTable.Rows[0].Cells[0].CssClass = "RowTitle";
yearTable.Rows[0].Height = 25;
yearTable.Rows[1].Height = 20;
yearTable.Rows[2].Height = 20;
for (int i = 0; i < 4; i++)
...{
yearTable.Rows[1].Cells.Add(new TableCell());
yearTable.Rows[1].Cells[i].CssClass = "RowTitle";
yearTable.Rows[2].Cells.Add(new TableCell());
yearTable.Rows[2].Cells[i].CssClass = "RowTitle";
}
yearTable.Rows[1].Cells[0].Text = "1Q" ;
yearTable.Rows[1].Cells[1].Text = "2Q" ;
yearTable.Rows[1].Cells[2].Text = "3Q" ;
yearTable.Rows[1].Cells[3].Text = "4Q" ;
yearTable.Rows[2].Cells[0].Text = "1Q";
yearTable.Rows[2].Cells[1].Text = "2Q";
yearTable.Rows[2].Cells[2].Text = "3Q";
yearTable.Rows[2].Cells[3].Text = "4Q";
Panel1.Controls.Add(yearTable);
//this.Controls.Add(yearTable);
}

//自定义 datatable
ICollection CreateDataSource( )
...{
System.Data.DataTable dt = new System.Data.DataTable();
System.Data.DataRow dr;
dt.Columns.Add(new System.Data.DataColumn("学生班级", typeof(System.String)));
dt.Columns.Add(new System.Data.DataColumn("学生姓名", typeof(System.String)));
dt.Columns.Add(new System.Data.DataColumn("语文", typeof(System.Decimal)));
dt.Columns.Add(new System.Data.DataColumn("数学", typeof(System.Decimal)));
dt.Columns.Add(new System.Data.DataColumn("英语", typeof(System.Decimal)));
dt.Columns.Add(new System.Data.DataColumn("计算机", typeof(System.Decimal)));
for (int i = 0 ; i < 50 ; i++)
...{
System.Random rd = new System.Random(Environment.TickCount * i); ;
dr = dt.NewRow();
dr[0] = "班级" + i.ToString();
dr[1] = "【孟子E章】" + i.ToString();
dr[2] = System.Math.Round(rd.NextDouble() * 100, 2);
dr[3] = System.Math.Round(rd.NextDouble() * 100, 2);
dr[4] = System.Math.Round(rd.NextDouble() * 100, 2);
dr[5] = System.Math.Round(rd.NextDouble() * 100, 2);
dt.Rows.Add(dr);
}
System.Data.DataView dv = new System.Data.DataView(dt);
return dv;
}
1943

被折叠的 条评论
为什么被折叠?



