How would I add a user to a role in (c#)

Posted on 2014-08-11
Last Modified: 2014-08-14
I'm trying to add a user to a row with the role manager but can't get it to work.  I would like the admin to be able to add role to users as needed.  I can't figure the code out.

this is what I have.  I have a gridview with the name of the user in it, when they click the button it put the user name in a label that i would like to use to assign the row to with my dorpdownlist of Roles.

Membership.ApplicationName = AppName.Text.ToString();
Roles.AddUsersToRole(selUser.Text, atRole.Text);

Open in new window

Question by:bmanmike39
    LVL 14

    Accepted Solution

    Great question! The most simple answer is to use the Web Site Administration Tool ASP.Net provides:

    After getting intitial testing out of the way, you undoubtedly will want to do this programmically. You can do this by calling Membership.CreateUser() as follows:

           out createStatus);

    Open in new window

    Also refer this link :

    Author Closing Comment

    Thank you!

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now