p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 8th, 2009, 09:15 PM
Authorized User
Points: 112, Level: 2
Points: 112, Level: 2 Points: 112, Level: 2 Points: 112, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2008
Location: San Antonio, TX, USA.
Posts: 26
Thanks: 3
Thanked 0 Times in 0 Posts
Default Want to delete all traces of a user account

Hello,

I have assembled an admin page (since someone at M$ apparently thought it would be cute to not let us use WSAT on a production server! ).

If you have an admin role, the page consists of a drop-down list from which you can select a username (the default is your own username), which in turn pulls up that user's account (not the profile, the login stuff) in a DetailsView control. Additionally, if the selected account is not your own, a Delete button is provided. (We don't want to accidentally delete ourselves!)

I specified in ObjectDataSource1 / DELETE tab the option that says "Boolean deleteAllRelatedData", but through trial and error, I have discovered that only the Membership table record was deleted, not the Users table record. This user did not create a profile, but I am assuming if she had, then this record would not be deleted, either.

I want all traces of this user completely deleted from the system entirely.

This will then solve the problem of why my "Select User" drop-down list still shows the deleted user, even though WSAT indicates the user no longer exists. (It was DB Explorer that tipped me off about Users and Profiles tables not being affected as they should have.)

Below is the ASPX code in question....

Code:
<h1>Edit User Accounts</h1>

<!-- SELECT USER ACCOUNT //-->

 

<div class="bottomblueline">
<asp:Label ID="Label1" runat="server" CssClass="bold" Text="Select User Name:&nbsp;" AssociatedControlID="ddlUserNames"></asp:Label>
<asp:DropDownList ID="ddlUserNames" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="UserName" DataValueField="UserName" TabIndex="1" onselectedindexchanged="ddlUserNames_SelectedIndexChanged"></asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SqlXpress %>" SelectCommand="SELECT [UserName] FROM [vw_aspnet_Users] ORDER BY [UserName]"></asp:SqlDataSource>
</div> <!-- DISPLAY USER ACCOUNT //--> <div class="topbottompadding">
<asp:DetailsView AutoGenerateRows="False" DataSourceID="ObjectDataSource1" ID="DetailsView1" runat="server" OnItemUpdating="DetailsView1_ItemUpdating" CellPadding="0" CssClass="noborderline" DefaultMode="Edit" GridLines="Horizontal" Width="100%" onitemcreated="DetailsView1_ItemCreated">
<Fields>
<asp:BoundField DataField="UserName" HeaderText="User Name" ReadOnly="True" SortExpression="UserName"/>
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" ControlStyle-Width="250px">
<ControlStyleWidth="250px"/>
</asp:BoundField>
<asp:BoundField DataField="PasswordQuestion" HeaderText="Password Question" ReadOnly="True" SortExpression="PasswordQuestion"></asp:BoundField>
<asp:CheckBoxField DataField="IsOnline" HeaderText="Online?" ReadOnly="True" SortExpression="IsOnline"/>
<asp:CheckBoxField DataField="IsApproved" HeaderText="Active?" SortExpression="IsApproved"/>
<asp:BoundField ControlStyle-Height="100px" ControlStyle-Width="250px" DataField="Comment" HeaderText="Comment" SortExpression="Comment">
<ControlStyle Height="100px" Width="250px"/>
</asp:BoundField>
<asp:BoundField DataField="CreationDate" HeaderText="Creation Date" ReadOnly="True" SortExpression="CreationDate"/>
<asp:BoundField DataField="LastActivityDate" HeaderText="Last Activity Date" ReadOnly="True" SortExpression="LastActivityDate"/>
<asp:BoundField DataField="LastLoginDate" HeaderText="Last Login Date" ReadOnly="True" SortExpression="LastLoginDate"/>
<asp:BoundField DataField="LastLockoutDate" HeaderText="Last Lockout Date" ReadOnly="True" SortExpression="LastLockoutDate"/>
<asp:BoundField DataField="LastPasswordChangedDate" HeaderText="Last Password Changed Date" ReadOnly="True" SortExpression="LastPasswordChangedDate"/>
<asp:BoundField DataField="ProviderName" HeaderText="Provider Name" ReadOnly="True" SortExpression="ProviderName"/>
<asp:BoundField DataField="ProviderUserKey" HeaderText="Provider User Key" ReadOnly="True" SortExpression="ProviderUserKey"/>
<asp:CommandField ButtonType="Button" ShowDeleteButton="True" ShowEditButton="True" UpdateText="Save Changes"></asp:CommandField>
<asp:CommandField ButtonType="Button" ShowEditButton="True" UpdateText="Save Changes"></asp:CommandField>
</Fields>
<CommandRowStyle CssClass="commandline"/>
<FieldHeaderStyle CssClass="bold"/>
<AlternatingRowStyle CssClass="gray"/>
</asp:DetailsView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetUser" TypeName="System.Web.Security.Membership" DeleteMethod="DeleteUser" OldValuesParameterFormatString="original_{0}">
<DeleteParameters>
<asp:ControlParameter ControlID="ddlUserNames" Name="username" PropertyName="SelectedValue" Type="String"/>
<asp:Parameter Name="deleteAllRelatedData" Type="Boolean" DefaultValue="True" />
</DeleteParameters>
<SelectParameters>
<asp:ControlParameter ControlID="ddlUserNames" DefaultValue=" " Name="username" PropertyName="SelectedValue" Type="String"/>
</SelectParameters>
</asp:ObjectDataSource>
</div>
Any thoughts on this? Thanks in advance!
__________________
~ Eddie McHam
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old July 9th, 2009, 07:01 PM
Authorized User
Points: 112, Level: 2
Points: 112, Level: 2 Points: 112, Level: 2 Points: 112, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2008
Location: San Antonio, TX, USA.
Posts: 26
Thanks: 3
Thanked 0 Times in 0 Posts
Talking

How weird. The problem went away.

Now Membership and Users tables delete the user, as desired.

The next hurdle was getting my "Select User Name" dropdown list (and its corresponding SqlDataSource) to update itself accordingly.

Tried ddlUserNames.DataBind() in numerous places along the page's lifecycle, to no avail until I discovered DetailsView1_ItemDeleted. That finally did the trick.

So now I have a living, breathing page that lets regular users add/update/remove their own email addresses and admin users do likewise PLUS approve/disapprove/delete other users' accounts (without accidentally nailing their own).

I shall now head home after a long, grueling day.....
__________________
~ Eddie McHam
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
chapter 15 -create user account melania BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 15 December 5th, 2008 05:53 PM
TO retrieive all user account name vinothsiva General .NET 1 June 15th, 2007 06:29 PM
How to creat an user account prad_a PHP Databases 1 May 12th, 2007 04:25 AM
Inactivate User Account NinaWilliam ASP.NET 1.0 and 1.1 Basics 5 March 13th, 2006 10:13 AM
Create User Account casselj ASP.NET 1.0 and 1.1 Professional 1 June 20th, 2005 09:34 AM



All times are GMT -4. The time now is 08:46 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc