<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:BlogConnectionString %>" 
            DeleteCommand="DELETE FROM [Admins] WHERE [AdminID] = @AdminID" 
            InsertCommand="INSERT INTO [Admins] ([AdminName], [Password], [sex], [department]) 
                           VALUES (@AdminName, @Password, @sex, @department)" 
            SelectCommand="SELECT * FROM [Admins]" 
            UpdateCommand="UPDATE [Admins] SET [AdminName] = @AdminName, [Password] = @Password, 
                           [sex] = @sex, [department] = @department WHERE [AdminID] = @AdminID">
            <DeleteParameters>
                <asp:Parameter Name="AdminID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="AdminName" Type="String" />
                <asp:Parameter Name="Password" Type="String" />
                <asp:Parameter Name="sex" Type="String" />
                <asp:Parameter Name="department" Type="String" />
                <asp:Parameter Name="AdminID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="AdminName" Type="String" />
                <asp:Parameter Name="Password" Type="String" />
                <asp:Parameter Name="sex" Type="String" />
                <asp:Parameter Name="department" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="AdminID" 
            DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="AdminID" HeaderText="用户编号" InsertVisible="False" 
                    ReadOnly="True" SortExpression="AdminID" >
                    <ControlStyle Width="100px" />
                </asp:BoundField>
                <asp:BoundField DataField="AdminName" HeaderText="用户名" 
                    SortExpression="AdminName" >
                    <ControlStyle Width="80px" />
                </asp:BoundField>
                <asp:BoundField DataField="Password" HeaderText="密码" 
                    SortExpression="Password" >
                    <ControlStyle Width="60px" />
                </asp:BoundField>
                <asp:BoundField DataField="sex" HeaderText="性别" SortExpression="sex" >
                    <ControlStyle Width="60px" />
                </asp:BoundField>
                <asp:BoundField DataField="department" HeaderText="所属部门" 
                    SortExpression="department" >
                    <ControlStyle Width="100px" />
                </asp:BoundField>
                <asp:CommandField HeaderText="编辑" ShowEditButton="True">
                    <ControlStyle Width="40px" />
                </asp:CommandField>
                <asp:TemplateField HeaderText="删除" ShowHeader="False">
                 <ItemTemplate>
                  <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" Text="删除" 
                    CommandName="Delete" OnClientClick="return confirm('确认要删除此条记录吗？');">
                  </asp:LinkButton>
                 </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    
    </div>
    </form>
</body>
</html>
