绑定Html.DropDownList

时间:2011-04-20 04:20:10

标签: asp.net-mvc-3 html.dropdownlistfor

在我的员工表中,字段类似于EmployeeID,FirstName,MiddleName,LastName,......就像那样。

我想将像EmployeeID这样的Html.DropDownList绑定为dataValueField,将FirstName + MiddleName + LAstName绑定为dataTextField。我怎么能这样绑定?

1 个答案:

答案 0 :(得分:0)

Create a partial class and set a property like this

    public string Name
    {
        get
        {
            return string.Format("{0} {1} {2}", FirstName, MiddleName, LastName);
        }
    }

Give 'Name' as the dataTextField