顶顶顶顶顶

①处理程序用到session

空间using System.Web.SessionState;   ashx类再继承IRequiresSessionState
ashx,打开 :右击选择模板打开,记得改继承ashx.cs文件的命名空间

②foreach for回顾基础

foreach是对集合(无序)arraylist,list,hastable,dictionary进行遍历,for对datatable, array(有序)

③vs中网站文件,f4属性,虚拟路径的作用。

④手动创建一个DateTable

 1  protected void Page_Load(object sender, EventArgs e)
 2         {
 3             //先创建表tb,再创建列col,add。
 4             //再创建多行tb.newrow,赋值,add。   一定先创建列没在创建行,因为行dt.newRow创建的。看下面。
 5             DataTable dt = new DataTable("cart");
 6             //dt.Columns.Add();
 7             DataColumn l0 = new DataColumn("编号", Type.GetType("System.Int32"));
 8             DataColumn l1 = new DataColumn("姓名", Type.GetType("System.String"));
 9             DataColumn l2 = new DataColumn("年龄", Type.GetType("System.Int16"));
10             DataColumn l3 = new DataColumn("身高", Type.GetType("System.Int16"));
11             DataColumn l4 = new DataColumn("视力", Type.GetType("System.Int64"));
12             DataColumn l5 = new DataColumn("创建时间", Type.GetType("System.DateTime"));
13             DataColumn[] col = { l0, l1, l2, l3, l4, l5, };
14             dt.Columns.AddRange(col);
15             for (int i = 0; i < 5; i++)
16             {
17                 DataRow row = dt.NewRow(); //new DataRow();
18                 row["编号"] = i + 1;
19                 row["姓名"] = "小王";
20                 row["年龄"] = 18;
21                 row["身高"] = 1516;
22                 row["视力"] = 15659;
23                 row["创建时间"] = "2015-4-25";
24                 dt.Rows.Add(row);
25             }
26             GridView1.DataSource = dt;
27             GridView1.DataBind();
28             //ListView1.DataSource = dt;
29             //ListView1.DataBind();//必须在 ListView“ListView1”上定义 ItemTemplate。
30         }
DateTable的手动创建,先创建表,列,从表.NewRow

相关文章:

  • 2022-01-08
  • 2022-12-23
  • 2021-11-09
  • 2021-09-16
  • 2021-05-06
  • 2021-10-16
  • 2021-04-18
  • 2021-09-15
猜你喜欢
  • 2021-12-10
  • 2022-12-23
  • 2021-05-01
  • 2021-06-25
  • 2022-12-23
  • 2022-01-03
  • 2021-12-13
相关资源
相似解决方案