2013-06-20 41 views
0

我在Company類中有List<BankAccount> Company_Accounts屬性。 對CreateCompany頁面一個或多個BankAccount信息正在動態輸入表格中。我想要javascript/jquery代碼迭代每一行並創建一個新的Account類型對象,並在Company_Accounts中創建此推送對象。在列表類型對象中迭代表和設置值

回答

0
// create your empty array, or get a previous array 
$(#tableid tr).each(function(index, element) { 
    // we are itering through every row of the table. Index is the number of the line (from 0), and element the line 
    // here some treatment to read the columns and create a new AccountType 
    // Check if same object already exist in table (maybe), if not push it back to the array 
}); 

在不知道對象原型的情況下無法幫助您,並且每次修改表時都想刷新數組。

0
class Company{ 
       string Name{get; set;} 
       string address{get;set;} 
       IList<BankAccount> Accounts{get; set;} 
      } 

class BankAccount{ 
        Company CompanyName{get; set;} 
        string BankName{get; set;} 
        string AccountNo{get; set;} 
        string BankAddress{get; set;} 
       } 
On create page for company i create and delete dynamically new BankAccount information by taking entry in Table's <td> cell having inputbox. 
I have to bind the List of newly created BankAccount to the CompanyModel on view page