Dictionary<string, EmployeeInfo> employeeInfoList = new Dictionary<string, EmployeeInfo>();
employeeInfoList = EmployeeInfoProxy.GetAllEmployeeInfo(TenantId);
if (employeeInfoList != null)
{
List<EmployeeInfo> employee = new List<EmployeeInfo>(employeeInfoList.Values);
ViewData["Name"] = employee[0].Name;
ViewData["Salary"] = employee[0].Salary;
ViewData["Department"] = employee[0].Department;
ViewData["Designation"] = employee[0].Designation;
ViewData["Address"] = employee[0].Address;
ViewData["Address1"] = employee[0].Address1;
}
上面的代碼工作正常。如果員工只有一條記錄,所以我已經硬編碼employee[0]
。動態列表值
,如果有更多的行,如何通過這些指標對員工(對於如員工,[\我應該動態地獲得的價值在這裏。
它總是更好地通過代碼和101010按代碼標記包圍代碼段。現在關於您的問題,您可以通過您的employeeInfoList。如果你不知道如何做到這一點,請按照這個http://dotnetperls.com/dictionary-keys – Waqas 2010-11-27 08:28:52