【发布时间】:2014-08-12 14:34:55
【问题描述】:
我想要下拉列表中的角色名称,但我的代码将其放入:System.Data.Entity.DynamicProxies.IdentityRole_9242DF3B1E41249C78E71E10BE06DC7180880D3BD461D49C4D7FA49EA1C455CA
var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>());
var roles = roleManager.Roles.ToList();
DropDownList1.DataSource = roles;
DropDownList1.DataBind();
我觉得这是我看不到的非常简单的错误。
感谢 Jeremy Cook 提供的正确答案。
新代码
var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>());
var roles = roleManager.Roles.ToList();
DropDownList1.DataTextField = "Name";
DropDownList1.DataValueField = "Id";
DropDownList1.DataSource = roles;
DropDownList1.DataBind();
【问题讨论】:
标签: c# asp.net entity-framework asp.net-identity