<%@ 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 %>" 
            
            SelectCommand="SELECT fname, lname, average, stno, sex, course FROM student" 
            DeleteCommand="DELETE FROM student WHERE (stno = @stno)" 
            UpdateCommand="UPDATE student SET fname = @fname, lname = @lname, average = @average, stno = @stno, sex = @sex, course = @course WHERE (stno = @stno)">
            <UpdateParameters>
                <asp:ControlParameter ControlID="DataList1" Name="stno" 
                    PropertyName="SelectedValue" />
                <asp:ControlParameter ControlID="DataList1" Name="fname" 
                    PropertyName="SelectedValue" />
                <asp:ControlParameter ControlID="DataList1" Name="lname" 
                    PropertyName="SelectedValue" />
                <asp:ControlParameter ControlID="DataList1" Name="average" 
                    PropertyName="SelectedValue" />
                <asp:ControlParameter ControlID="DataList1" Name="sex" 
                    PropertyName="SelectedValue" />
                <asp:ControlParameter ControlID="DataList1" Name="course" 
                    PropertyName="SelectedValue" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:DataList ID="DataList1" runat="server" DataKeyField="stno" 
            DataMember="DefaultView" DataSourceID="SqlDataSource1" RepeatColumns="2" 
            oncancelcommand="DataList1_CancelCommand" 
            ondeletecommand="DataList1_DeleteCommand" oneditcommand="DataList1_EditCommand" 
            onitemcommand="DataList1_ItemCommand" 
            onselectedindexchanged="DataList1_SelectedIndexChanged" 
            onupdatecommand="DataList1_UpdateCommand" style="margin-right: 0px">
            <ItemTemplate>
                fname:
                <asp:Label ID="fnameLabel" runat="server" Text='<%# Eval("fname") %>' />
                <br />
                lname:
                <asp:Label ID="lnameLabel" runat="server" Text='<%# Eval("lname") %>' />
                <br />
                average:
                <asp:Label ID="averageLabel" runat="server" Text='<%# Eval("average") %>' />
                <br />
                stno:
                <asp:Label ID="stnoLabel" runat="server" Text='<%# Eval("stno") %>' />
                <br />
                sex:
                <asp:Label ID="sexLabel" runat="server" Text='<%# Eval("sex") %>' />
                <br />
                course:
                <asp:Label ID="courseLabel" runat="server" Text='<%# Eval("course") %>' />
                <br />
                <br />
                <asp:Button ID="Button1" runat="server" CommandName="delete" 
                     Text="Delete" />
                <asp:Button ID="Button2" runat="server" CommandName="select" 
                     Text="Select" />
                <asp:Button ID="Button3" runat="server" CommandName="unselect" 
                     Text="Unselect" />
                <asp:Button ID="Button4" runat="server" CommandName="edit" 
                     Text="Edit" />
                
            </ItemTemplate>
            <EditItemTemplate>
                fname: <asp:TextBox ID="textfname" runat="server" 
                         Text='<%# Eval("fname") %>'>
                      </asp:TextBox>
                <br />
                lname: <asp:TextBox ID="textlname" 
                                 runat="server" 
                        Text='<%# Eval("lname") %>'>
                     </asp:TextBox>
                <br />
                average: <asp:TextBox ID="textaverage" 
                                 runat="server" 
                        Text='<%# Eval("average") %>'>
                     </asp:TextBox>
                <br />
               stno: <asp:Label ID="Label2" runat="server" 
                         Text='<%# Eval("stno") %>'>
                    </asp:Label>
                <br />
                sex: <asp:CheckBox ID="checkedsex" 
                                 runat="server" 
                        Checked='<%# Eval("sex") %>'>
                     </asp:CheckBox>
                <br />
                course: <asp:TextBox ID="textcourse" 
                                 runat="server" 
                        Text='<%# Eval("course") %>'>
                     </asp:TextBox>
                <br />
                <asp:LinkButton ID="LinkButton1" runat="server" 
                    CommandName="update" Text = "Update">
                   
                </asp:LinkButton>
                &nbsp;
                <asp:LinkButton ID="LinkButton2" runat="server" 
                 CommandName="cancel" Text = "Cancel">
                </asp:LinkButton>
            </EditItemTemplate>
            
        </asp:DataList>
    
    </div>
    </form>
</body>
</html>
