Bind a users role to dropdown?

Posted by Dynde on Stack Overflow See other posts from Stack Overflow or by Dynde
Published on 2010-03-18T10:28:53Z Indexed on 2010/03/18 10:31 UTC
Read the original article Hit count: 403

Filed under:
|
|
|

Hi...

I'm trying to bind a selected user's role to a dropdown-list. The purpose of this is to be able to change said user's role.

I'm attempting this inside a formview hooked up to a linqdatasource which contains a row from the aspnet_User table.

The dropdown list is hooked up to a linqdatasource of all the roles in the aspnet_Roles table (with DataValueField="RoleID", DataTextField="RoleName").

I figured it would be possible with something like:

SelectedValue='<%# Bind("aspnet_UsersInRole[0].aspnet_Role.RoleID") %>'

But this throws a parser exception, about the bind call not being correctly formatted.

The roles are there, they show up when I remove the "SelectedValue"

Can anyone point me in the right direction?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about roles