迭代表并在List类型对象中设置值
本文关键字:对象 设置 类型 List 迭代 | 更新日期: 2023-09-27 18:19:06
我在Company
类中有一个List<BankAccount> Company_Accounts
属性。在CreateCompany
页上,一个或多个BankAccount
信息正在动态地在表中输入。我想要javascript/jquery代码迭代每一行,并创建一个新的Account
类型的对象和这个推对象在Company_Accounts
。
// 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
});
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