2011-01-24 66 views

回答

1
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); 
    } 
} 

它可能是更好地从你的角色直读的是相当缓慢到成员表。

+0

但是,我如何将角色信息与用户的其他信息相结合,并将它们绑定在我的datagridview中? – 2011-01-24 05:56:30