<%@ Page Language="C#" MasterPageFile="~/default.master" %>
<asp:Content ID="c1" runat="server" ContentPlaceHolderID="head">
    <title>Tootekirjelduste leht</title>
</asp:Content>

<asp:Content ID="c2" runat="server" ContentPlaceHolderID="sisu">
 
       
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:veebipoebaasConnectionString %>" 
            DeleteCommand="DELETE FROM [tooted] WHERE [id] = @id" 
            InsertCommand="INSERT INTO [tooted] ([nimetus], [hind], [koguslaos], [pildiURL]) VALUES (@nimetus, @hind, @koguslaos, @pildiURL)" 
            SelectCommand="SELECT [id], [nimetus], [hind], [koguslaos], [pildiURL] FROM [tooted]" 
            
            UpdateCommand="UPDATE [tooted] SET [nimetus] = @nimetus, [hind] = @hind, [koguslaos] = @koguslaos, [pildiURL] = @pildiURL WHERE [id] = @id">
            <DeleteParameters>
                <asp:Parameter Name="id" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="nimetus" Type="String" />
                <asp:Parameter Name="hind" Type="Decimal" />
                <asp:Parameter Name="koguslaos" Type="Int32" />
                <asp:Parameter Name="pildiURL" Type="String" />
                <asp:Parameter Name="id" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="nimetus" Type="String" />
                <asp:Parameter Name="hind" Type="Decimal" />
                <asp:Parameter Name="koguslaos" Type="Int32" />
                <asp:Parameter Name="pildiURL" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
       
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            DataKeyNames="id" DataSourceID="SqlDataSource1">
            <Columns>
                <asp:CommandField ShowEditButton="True" />
                <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" 
                    ReadOnly="True" SortExpression="id" />
                <asp:BoundField DataField="nimetus" HeaderText="nimetus" 
                    SortExpression="nimetus" />
                <asp:BoundField DataField="hind" HeaderText="hind" SortExpression="hind" />
                <asp:BoundField DataField="koguslaos" HeaderText="koguslaos" 
                    SortExpression="koguslaos" />
              <%--  <asp:BoundField DataField="pildiURL" HeaderText="pildiURL" 
                    SortExpression="pildiURL" /> --%>
            </Columns>
        </asp:GridView>
        <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
            DataKeyNames="id" DataSourceID="SqlDataSource1" DefaultMode="Insert" 
            Height="50px" Width="125px">
            <Fields>
                <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" 
                    ReadOnly="True" SortExpression="id" />
                <asp:BoundField DataField="nimetus" HeaderText="nimetus" 
                    SortExpression="nimetus" />
                <asp:BoundField DataField="hind" HeaderText="hind" SortExpression="hind" />
                <asp:BoundField DataField="koguslaos" HeaderText="koguslaos" 
                    SortExpression="koguslaos" />
                <asp:BoundField DataField="pildiURL" HeaderText="pildiURL" 
                    SortExpression="pildiURL" />
                <asp:CommandField ShowInsertButton="True" />
            </Fields>
        </asp:DetailsView>
        <br />
</asp:Content>