2011-04-20 66 views
0

在我的Employee表中,字段類似於EmployeeID,FirstName,MiddleName,LastName,...就像那樣。綁定Html.DropDownList

我想綁定我的Html.DropDownList像EmployeeID作爲dataValueField和FirstName + MiddleName + LAstName作爲dataTextField。我該如何綁定?

回答

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 
+0

謝謝,這解決了我的問題。非常感謝。 – Mukesh 2011-04-20 04:36:31