开发者

Bind Html.DropDownList

开发者 https://www.devze.com 2023-02-26 23:53 出处:网络
In my Employee table, fields are like EmployeeID, FirstName, MiddleName, LastNam开发者_如何学Ce ,... like that.

In my Employee table, fields are like EmployeeID, FirstName, MiddleName, LastNam开发者_如何学Ce ,... like that.

I want to bind my Html.DropDownList like EmployeeID as dataValueField and FirstName+MiddleName+LAstName as dataTextField. How can I bind like this?


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
0

精彩评论

暂无评论...
验证码 换一张
取 消