迭代表并在List类型对象中设置值

时间:2013-06-20 09:54:41

标签: c# jquery html javascript-events knockout.js

我在课程List<BankAccount> Company_Accounts中有一个Company属性。 在CreateCompany页面上动态输入一个或多个BankAccount个信息。我希望javascript / jquery代码迭代每一行,并在Account中创建一个新的Company_Accounts类型对象和这个推送对象。

2 个答案:

答案 0 :(得分: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
});

在不知道对象原型的情况下无法帮助您,并且每次修改表时是否想要刷新数组。

答案 1 :(得分: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