Question

App: Silvelight 4 Business app template + RIA services + C#. I combined the aspnet membership db into my database. I'm able to register user, login and logout.

I need to be able to assign users roles from the application/client-side UI. There are 3 roles in the aspnet membership i created using the config tool.

I created an extra table "UserAccess" that has the UserId from aspnet_Users table as FK,the RoleID from aspnet_Roles table as FK and Startdate as PK.

Entities generated using ADO.net Entity data model. Domain service class generated usign these entities.

In the service class file i added "include" keyword to

UserAccesses.Include("aspnet_Users").Include("aspnet_Roles");

In metadata file

[Include]
public aspnet_Roles aspnet_Roles { get; set; }
[Include]
public aspnet_Users aspnet_Users { get; set; }

since I had navigation properties on them.

I used the domain datasource(RIA controls) and dragged the datagrid onto my page. I set the Roles to combobox. I was successfully able to load the table,including the username and the rolename from the other tables. By default everything is showing-up correctly.

<ComboBoxItem Content="{Binding Path=aspnet_Roles.RoleName, Mode=TwoWay}" />

But when I click on the cell/combobox i want to load the 3 available roles so that the user can edit/choose and submit changes? How can I achieve this?

Cheers

Was it helpful?

Solution

You have to load aspnet_Roles table rows and bind it to ComboBox. You need to store it in a seperate property and Bind it like this

ItemSource={Binding Path=Roles, Source={StaticResource YourViewModel}}"

Cheers! Vinod

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top