本文介绍了从视图状态到列表获取数据(视图状态具有表)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在一个像下面这样的列表中有一个数据,现在我想从已经包含表的viewstate中获取数据,我想要一列.我该怎么办?

Suppose I have a data in a list like below and now I want to get data from viewstate which already contain table in that I want one column. How can I do that?

public List<Employee> GetEmployeeList()
    {
        List<Employee> empList = new List<Employee>();
        empList.Add(new Employee() { ID = 1, Email = "[email protected]"});
        empList.Add(new Employee() { ID = 2, Email = "[email protected]"});
        empList.Add(new Employee() { ID = 3, Email = "[email protected]"});
            empList.Add(new Employee() { ID = 8, Email = "[email protected]"});
        empList.Add(new Employee() { ID = 9, Email = "[email protected]"});
        empList.Add(new Employee() { ID = 10, Email = "[email protected]" });
        return empList;
    }

推荐答案

for(rowIndex=0; rowIndex<datatable.rows.count;>{
string columnValue = dataTable.Rows[rowIndex]["email"];
Employee emp = new Employee(){ID=someID, Email=columnValue});
}



希望对您有所帮助.
谢谢,
Hemant



Hope it will help.
thanks,
Hemant


这篇关于从视图状态到列表获取数据(视图状态具有表)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 13:49