asp.net 小总结

//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() * 1002);
      dr[
3= System.Math.Round(rd.NextDouble() * 1002);
      dr[
4= System.Math.Round(rd.NextDouble() * 1002);
      dr[
5= System.Math.Round(rd.NextDouble() * 1002);
      dt.Rows.Add(dr);
    }

    System.Data.DataView dv 
= new System.Data.DataView(dt);
    
return dv;
  }

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值