2012-05-20 136 views
0

我實現下面的方法來獲得部門陣列結合DROPDOWNLIST插入對象

public object[] GetDepartmentOptions() 
{ 
    var departments = from p in context.per_Departments 
        where p.active == true 
        select new { DisplayText = p.departmentNameEn, 
            Value = p.departmentId }; 
    return departments.ToArray(); 
} 

我想將其綁定

object =new { DisplayText = "Choose", Value = 0 }; 

回答

2

對於之前插入對象此數組中某些原因,只有當您的第一個序列是「選擇」序列時纔有效:

var first = new[] { new { DisplayText = "Choose", Value = 0 } }; 
    return first.Concat(departments).ToArray(); 
+0

謝謝你的幫助 –