1
我正在使用Membership.GetAllUsers()
函数获取用户列表。我在网格视图中绑定这些数据。如何在ASP.NET中显示角色?
但我在这里找不到角色信息。我需要在该网格视图中显示角色。
我该怎么办?
我正在使用Membership.GetAllUsers()
函数获取用户列表。我在网格视图中绑定这些数据。如何在ASP.NET中显示角色?
但我在这里找不到角色信息。我需要在该网格视图中显示角色。
我该怎么办?
Roles.GetRolesForUser(user)
http://msdn.microsoft.com/en-us/library/8h930x07.aspx
UPDATE
这是怎么回事,如果你有很多用户
GridView.RowDataBound += new GridViewRowEventHandler(GridView_RowDataBound);
void GridView_RowDataBound(object sender, GridViewRowEventArgs e) {
GridView gridview = (GridView)sender;
if (e.Row.RowType == DataControlRowType.DataRow) {
string username = DataBinder.Eval(e.Row.DataItem, "yourusernamecolumn").ToString();
Literal c = new Literal();
c.Text = Roles.GetRolesForUser(username).ToString(); //decide how you want to display the list
e.Row.Cells[somecolumnindex].Controls.Add(c);
}
}
它可能是更好地从你的角色直读的是相当缓慢到成员表。
但是,我如何将角色信息与用户的其他信息相结合,并将它们绑定在我的datagridview中? – 2011-01-24 05:56:30