Hi all I have a page that shows Accommodation info and then the UserID of the person that created that information in a DetailsView.
I also have a button that should look at that that UserID and when clicked take that userID convert it to a username so that then I can use that username to change the persons role to a renter. However I am unsure using C# how I can grab the UserID from details view do the conversion and update the role. Any ideas?
Mark
@Tim
Here is the code I have added:
public partial class adminonly_approval : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
void DetailsView1_ItemCommand(Object sender, DetailsViewCommandEventArgs e){
if (e.CommandName == "SetToRenter")
{
// if UserID is in second row:
DetailsViewRow row = DetailsView1.Rows[9];
// Get the Username from the appropriate cell.
// In this example, the Username is in the second cell
String UserID = row.Cells[9].Text;
MembershipUser memUser = Membership.GetUser(UserID);
Roles.AddUserToRole(memUser.UserName, "renter");
}
}
I Have added a button on the page below the details view and set the commandName to SetToRenter. When I click the button though it isn't changing the roles. Im new to ASP and C# but need this feature for a university assignment. Any Idea?