<%@ 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:universityConnectionString %>" 
            DeleteCommand="DELETE FROM student WHERE (stno = @stno)" 
            InsertCommand="INSERT INTO student(fname, lname, average, stno, sex, course) VALUES (@fname, @lname, @average, @stno, @sex, @course)" 
            SelectCommand="SELECT * FROM [student]" 
            UpdateCommand="UPDATE student SET fname = @fname, lname = @lname, average = @average, stno = @stno, sex = @sex, course = @course WHERE (stno = @stno)"></asp:SqlDataSource>
    
        <asp:FormView ID="FormView1" runat="server" AllowPaging="True" 
            DataKeyNames="stno" DataSourceID="SqlDataSource1">
            <PagerSettings FirstPageText="First" LastPageText="Last" Mode="NextPrevious" 
                NextPageText="Next" PreviousPageText="Prev" />
            <EditItemTemplate>
                fname:
                <asp:TextBox ID="fnameTextBox" runat="server" Text='<%# Bind("fname") %>' />
                <br />
                lname:
                <asp:TextBox ID="lnameTextBox" runat="server" Text='<%# Bind("lname") %>' />
                <br />
                average:
                <asp:TextBox ID="averageTextBox" runat="server" Text='<%# Bind("average") %>' />
                <br />
                stno:
                <asp:TextBox ID="stnoTextBox" runat="server" Text='<%# Bind("stno") %>' />
                <br />
                sex:
                <asp:CheckBox ID="sexCheckBox" runat="server" Checked='<%# Bind("sex") %>' />
                <br />
                course:
                <asp:TextBox ID="courseTextBox" runat="server" Text='<%# Bind("course") %>' />
                <br />
                <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                    CommandName="Update" Text="Update" />
                &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                    CausesValidation="False" CommandName="Cancel" Text="Cancel" />
            </EditItemTemplate>
            <InsertItemTemplate>
                fname:
                <asp:TextBox ID="fnameTextBox" runat="server" Text='<%# Bind("fname") %>' />
                <br />
                lname:
                <asp:TextBox ID="lnameTextBox" runat="server" Text='<%# Bind("lname") %>' />
                <br />
                average:
                <asp:TextBox ID="averageTextBox" runat="server" Text='<%# Bind("average") %>' />
                <br />
                stno:
                <asp:TextBox ID="stnoTextBox" runat="server" Text='<%# Bind("stno") %>' />
                <br />
                sex:
                <asp:CheckBox ID="sexCheckBox" runat="server" Checked='<%# Bind("sex") %>' />
                <br />
                course:
                <asp:TextBox ID="courseTextBox" runat="server" Text='<%# Bind("course") %>' />
                <br />
                <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                    CommandName="Insert" Text="Insert" />
                &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                    CausesValidation="False" CommandName="Cancel" Text="Cancel" />
            </InsertItemTemplate>
            <ItemTemplate>
                fname:
                <asp:Label ID="fnameLabel" runat="server" Text='<%# Bind("fname") %>' />
                <br />
                lname:
                <asp:Label ID="lnameLabel" runat="server" Text='<%# Bind("lname") %>' />
                <br />
                average:
                <asp:Label ID="averageLabel" runat="server" Text='<%# Bind("average") %>' />
                <br />
                stno:
                <asp:Label ID="stnoLabel" runat="server" Text='<%# Bind("stno") %>' />
                <br />
                sex:
                <asp:CheckBox ID="sexCheckBox" runat="server" Checked='<%# Bind("sex") %>' 
                    Enabled="false" />
                <br />
                course:
                <asp:Label ID="courseLabel" runat="server" Text='<%# Bind("course") %>' />
                <br />
                <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                    CommandName="Edit" Text="Edit" />
                &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                    CommandName="Delete" Text="Delete" />
                &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                    CommandName="New" Text="New" />
            </ItemTemplate>
        </asp:FormView>
    
    </div>
    </form>
</body>
</html>
