我有问题,我在mvc telerik网格中有下拉列表,每件事情都可以,只有问题是我在下拉列表中添加空间但是空间显示下拉列表的底部我希望它在下拉列表中的空间我的代码是
控制器代码:
private void Grid_PopulateAssignedClientCombo()
{
IEnumerable<AssignedClient> ass= assetManagementService.GetAssignedClients();
IList<AssignedClient> l =new List<AssignedClient>();
AssignedClient a = new AssignedClient();
l = ass.ToList();
a.ID = 0;
a.RefAssignedClient_DESC=string.Empty;
l.Add(a);
ViewData["assignedClients"] = l.Select(e => new AssignedClient{ ID = e.ID, RefAssignedClient_DESC= e.RefAssignedClient_DESC});
}
Editor template
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%= Html.Telerik().DropDownList()
.Name("AssignedClient")
.BindTo(new SelectList((IList)ViewData["assignedClients"],"RefAssignedClient_DESC", "RefAssignedClient_DESC"))
%>
任何人都可以告诉我如何做到这一点。
由于
答案 0 :(得分:1)
更改
l.Add(a);
到
l.Insert(0, a);
答案 1 :(得分:1)
您可以按ID添加订单。喜欢
l.orderby(p=>p.ID);