2012-04-30 25 views
0

我有我的頁面網格有四列與多行 用戶ID的用戶名和STATEID Statename的數據網格行中收集保存和顯示在另一頁asp.net

其收集我應該用數據發送到另一個使用會話頁面 我的代碼是

string[] strArray = new string[] {}; 

     foreach (GridViewRow gr in gvCompany.Rows) 
     { 
      strArray =new string[4] {new[] {gr.Cells[0].Text}.ToString(), new[] {gr.Cells[1].Text}.ToString(), new[] {gr.Cells[2].Text}.ToString(),new[] {gr.Cells[3].Text}.ToString()}; 


     } 
     Session["List"] = strArray; 
     Response.Redirect("Tid.aspx?Mode=List"); 

TID網頁上我的代碼是

string[] ls = new string[] { }; 
        ls =(string[]) Session["List"]; 
       foreach (string st in ls) 
       { 
        //get each cell 
       } 

但ST的價值體系.string而不是價值

回答

1

使用的字符串[],因爲更多的領域,不建議將在未來的困難會得到保持田間和指數的關係的bug免費添加..

您可以創建一個適當的類對象例如。公司並將List傳遞給其他類,List位於System.Collections.Generic命名空間中。

相關問題