如何在ASP.NET Membership DB中管理用户?

时间:2014-03-14 15:18:56

标签: c# asp.net membership

我正在为我的网站使用ASP.NET Membership(createUserWizard)signUp。现在我想管理由createuserwizard注册的用户,这意味着我想编辑角色并从所有asp.net表中删除用户。 为此我有一个连接到sqlDatasourse的gridview。我在sqldatasourse手动编写连接字符串代码所以我不能在数据中使用高级(删除,更新,插入)。我怎么能用我自己的鳕鱼做这项工作?

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="manage-users.aspx.cs" Inherits="manage_users" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" 
    AutoGenerateColumns="False" AllowPaging="True" AllowSorting="True">
    <Columns>
        <asp:BoundField DataField="UserName" HeaderText="نام کاربری" 
            SortExpression="UserName" />
        <asp:BoundField DataField="LastActivityDate" HeaderText="تاریخ آخرین فعالیت " 
            SortExpression="LastActivityDate" />
        <asp:BoundField DataField="Email" HeaderText="ایمیل " SortExpression="Email" />
        <asp:CheckBoxField DataField="IsApproved" HeaderText="فعال" 
            SortExpression="IsApproved" />
        <asp:CheckBoxField DataField="IsLockedOut" HeaderText="مسدود" 
            SortExpression="IsLockedOut" />
        <asp:BoundField DataField="LastLockoutDate" HeaderText="تاریخ آخرین مسدودیت" 
            SortExpression="LastLockoutDate" />
        <asp:BoundField DataField="RoleName" HeaderText="نقش کاربری" 
            SortExpression="RoleName" />
    </Columns>
</asp:GridView>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:akhbarrConnectionString %>"  
    ProviderName="<%$ ConnectionStrings:SabteAKhabar.ProviderName %>" 
    SelectCommand="SELECT aspnet_Users.UserName, aspnet_Users.LastActivityDate, aspnet_Membership.Email, aspnet_Membership.IsApproved, aspnet_Membership.IsLockedOut, aspnet_Membership.LastLockoutDate, aspnet_Roles.RoleName FROM aspnet_Users INNER JOIN aspnet_Membership ON aspnet_Membership.UserId = aspnet_Users.UserId INNER JOIN aspnet_UsersInRoles ON aspnet_UsersInRoles.UserId = aspnet_Users.UserId INNER JOIN aspnet_Roles ON aspnet_Roles.RoleId = aspnet_UsersInRoles.RoleId"></asp:SqlDataSource>

</asp:Content>

0 个答案:

没有答案