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

<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" OnRowDeleting="GridView1_RowDeleting" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None">
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="True" />
                <asp:BoundField DataField="UNIT_NO" HeaderText="UNIT_NO" SortExpression="UNIT_NO" />
                <asp:BoundField DataField="UNIT_NAME" HeaderText="UNIT_NAME" SortExpression="UNIT_NAME" />
            </Columns>
            <FooterStyle BackColor="Tan" />
            <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
            <HeaderStyle BackColor="Tan" Font-Bold="True" />
            <AlternatingRowStyle BackColor="PaleGoldenrod" />
        </asp:GridView>
    
    </div>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringOleOraWalcom %>"
            OldValuesParameterFormatString="original_{0}" DeleteCommand="delete from units where unit_no=:unit_no and unit_name=:unit_name" InsertCommand="insert into units(UNIT_Name) values(:unit_name)"
            ProviderName="<%$ ConnectionStrings:ConnectionStringOleOraWalcom.ProviderName %>"
            SelectCommand="select UNIT_NO, UNIT_NAME from units" 
            UpdateCommand="update units set UNIT_NAME=:unit_name where UNIT_NO=:unit_no">
            <DeleteParameters>
                <asp:Parameter Name="unit_no" />
                <asp:Parameter Name="unit_name" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="unit_name" />
                <asp:Parameter Name="unit_no" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="unit_name" />
            </InsertParameters>
        </asp:SqlDataSource>
        <br />
        <br />
        <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1" DefaultMode="Insert">
            <EditItemTemplate>
                UNIT_NO:
                <asp:TextBox ID="UNIT_NOTextBox" runat="server" Text='<%# Bind("UNIT_NO") %>'>
                </asp:TextBox><br />
                UNIT_NAME:
                <asp:TextBox ID="UNIT_NAMETextBox" runat="server" Text='<%# Bind("UNIT_NAME") %>'>
                </asp:TextBox><br />
                <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                    Text="Update">
                </asp:LinkButton>
                <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                    Text="Cancel">
                </asp:LinkButton>
            </EditItemTemplate>
            <InsertItemTemplate>
                UNIT_NAME:
                <asp:TextBox ID="UNIT_NAMETextBox" runat="server" Text='<%# Bind("UNIT_NAME") %>'></asp:TextBox><br />
                <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                    Text="Insert"></asp:LinkButton>
                <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                    Text="Cancel"></asp:LinkButton>
            </InsertItemTemplate>
            <ItemTemplate>
                UNIT_NO:
                <asp:Label ID="UNIT_NO" runat="server" Text='<%# Bind("UNIT_NO") %>'></asp:Label><br />
                UNIT_NAME:
                <asp:Label ID="UNIT_NAMELabel" runat="server" Text='<%# Bind("UNIT_NAME") %>'></asp:Label><br />
                <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
                    Text="Edit"></asp:LinkButton>
                <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
                    Text="Delete"></asp:LinkButton>
                <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
                    Text="New"></asp:LinkButton>
            </ItemTemplate>
        </asp:FormView>
        <asp:Label ID="Label1" runat="server"></asp:Label>
        <br />
        <br />
    </form>
</body>
</html>
