0

Have a gridview that lists users who are locked out of the system. Admin staff can go on to this unlockuser page where the gridview will be displayed with the users various details, theres an unlock button on every row for each user. Just wondering what way to write the back end code for the gridview row command? So far I have

  MembershipUser usr = Membership.GetUser();
                usr.UnlockUser();

How do I get the user id into this? Do I need to declare it as a variable somewhere in the code behind?

2
Contributors
3
Replies
19
Views
4 Years
Discussion Span
Last Post by AleMonteiro
0

In your gridview itemtemplate button, you should add the commandArgument, like this:

<asp:button .... CommandArgument='<%#Eval("UserId") %>' />

Then, in the BackEnd, on your RowCommand event, you can get the userId like this:

int UserId = int.Parse(e.CommandArgument.ToString())

0

Thats great, thank you. Any idea how I update the database table so that the isLockedOut field changes to false and then update the gridview to display the remaining locked out users?

0

I never used asp.net membership providers, so I can't help much with that.

But in plain SQL, it would be like this:

UPDATE [myUserTable] SET [myLockedField] = 0 WHERE [myUserIdField] = @UserId

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.