Code
1 private DataTable ReadGridView()
2 {
3 DataTable newDataTable = new DataTable("Table1");
4
5 newDataTable = CreateTable();
6
7
8 for (int i = 0; i < this.gv_productlist.Rows.Count; i++)
9 {
10 GridViewRow gRow = gv_productlist.Rows[i];
11 DataRow newrow = newDataTable.NewRow();
12 // newRow[""] = L_ModelType
13 newrow["ProjectGuid"] = L_guidvalue.Text;
14 newrow["ProdGuid"] = ((Label)gRow.FindControl("L_prodguid")).Text;
15 newrow["fldNum"] = ((TextBox)gRow.FindControl("txt_fldnum")).Text;
16 newrow["fldEndDate"] = ((Label)gRow.FindControl("L_EndDate")).Text; ; ;
17 newrow["fldModelType"] = ((Label)gRow.FindControl("L_ModelType")).Text;
18 newrow["fldModelTypeSj"] = ((TextBox)gRow.FindControl("txt_fldModelTypeSj")).Text;
19 newrow["ID"] = ((Label)gRow.FindControl("L_NO")).Text;
20 newDataTable.Rows.Add(newrow);
21 }
22 newDataTable.AcceptChanges();
23 return newDataTable;
24
25 }
26
1 private DataTable ReadGridView()
2 {
3 DataTable newDataTable = new DataTable("Table1");
4
5 newDataTable = CreateTable();
6
7
8 for (int i = 0; i < this.gv_productlist.Rows.Count; i++)
9 {
10 GridViewRow gRow = gv_productlist.Rows[i];
11 DataRow newrow = newDataTable.NewRow();
12 // newRow[""] = L_ModelType
13 newrow["ProjectGuid"] = L_guidvalue.Text;
14 newrow["ProdGuid"] = ((Label)gRow.FindControl("L_prodguid")).Text;
15 newrow["fldNum"] = ((TextBox)gRow.FindControl("txt_fldnum")).Text;
16 newrow["fldEndDate"] = ((Label)gRow.FindControl("L_EndDate")).Text; ; ;
17 newrow["fldModelType"] = ((Label)gRow.FindControl("L_ModelType")).Text;
18 newrow["fldModelTypeSj"] = ((TextBox)gRow.FindControl("txt_fldModelTypeSj")).Text;
19 newrow["ID"] = ((Label)gRow.FindControl("L_NO")).Text;
20 newDataTable.Rows.Add(newrow);
21 }
22 newDataTable.AcceptChanges();
23 return newDataTable;
24
25 }
26
Code
1
2 public void BindList()
3 {
4 // DataTable table = CreateTable();
5
6 DataTable sTable = new DataTable();
7 sTable = ReadGridView();
8 if (id == 0)
9 {
10 if (Session[L_guidvalue.Text.Trim()] != null)
11 {
12 DataTable tb = new DataTable();
13 tb = Session[L_guidvalue.Text.Trim()] as DataTable;
14 //table = Session[L_guidvalue.Text.Trim()] as DataTable;
15 for (int i = 0; i < tb.Rows.Count; i++)
16 {
17 sTable.ImportRow(tb.Rows[i]);
18 }
19 }
20 }
21 else
22 {
23 //如果有session则里面读取
24 if (Session[L_guidvalue.Text.Trim()] != null)
25 {
26 DataTable tb = new DataTable();
27 tb = Session[L_guidvalue.Text.Trim()] as DataTable;
28 for (int i = 0; i < tb.Rows.Count; i++)
29 {
30 sTable.ImportRow(tb.Rows[i]);
31 }
32
33 }
34 else
35 {//如果没有则从库中读取
36 sTable = GetTableInfo();
37
38 }
39 Session[L_guidvalue.Text.Trim()] = sTable;
40 }
41 this.gv_productlist.DataSource = null;
42 this.gv_productlist.DataSource = sTable;
43 //this.gv_productlist.PageSize = AspNetPager2.PageSize;
44 //gv_productlist.PageIndex = AspNetPager2.CurrentPageIndex - 1;
45 AspNetPager2.RecordCount = sTable.Rows.Count;
46 this.gv_productlist.DataBind();
47 //Session[L_guidvalue.Text.Trim()] = null;
48 }
1
2 public void BindList()
3 {
4 // DataTable table = CreateTable();
5
6 DataTable sTable = new DataTable();
7 sTable = ReadGridView();
8 if (id == 0)
9 {
10 if (Session[L_guidvalue.Text.Trim()] != null)
11 {
12 DataTable tb = new DataTable();
13 tb = Session[L_guidvalue.Text.Trim()] as DataTable;
14 //table = Session[L_guidvalue.Text.Trim()] as DataTable;
15 for (int i = 0; i < tb.Rows.Count; i++)
16 {
17 sTable.ImportRow(tb.Rows[i]);
18 }
19 }
20 }
21 else
22 {
23 //如果有session则里面读取
24 if (Session[L_guidvalue.Text.Trim()] != null)
25 {
26 DataTable tb = new DataTable();
27 tb = Session[L_guidvalue.Text.Trim()] as DataTable;
28 for (int i = 0; i < tb.Rows.Count; i++)
29 {
30 sTable.ImportRow(tb.Rows[i]);
31 }
32
33 }
34 else
35 {//如果没有则从库中读取
36 sTable = GetTableInfo();
37
38 }
39 Session[L_guidvalue.Text.Trim()] = sTable;
40 }
41 this.gv_productlist.DataSource = null;
42 this.gv_productlist.DataSource = sTable;
43 //this.gv_productlist.PageSize = AspNetPager2.PageSize;
44 //gv_productlist.PageIndex = AspNetPager2.CurrentPageIndex - 1;
45 AspNetPager2.RecordCount = sTable.Rows.Count;
46 this.gv_productlist.DataBind();
47 //Session[L_guidvalue.Text.Trim()] = null;
48 }