Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
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 Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 8th, 2009, 08:15 PM
Authorized User
 
Join Date: Dec 2008
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
 
Old July 9th, 2009, 06:01 PM
Authorized User
 
Join Date: Dec 2008
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





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 05:29 PM
How to creat an user account prad_a PHP Databases 1 May 12th, 2007 03: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 08:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.