Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Nested GridView [No JavaScripts]

, 19 Jul 2009 CPOL
Nesting GridViews without writing any JavaScript code [AJAX driven].
nested_gv.zip
ICONS
finance.png
HGHGH.jpg
home.png
inv.png
Main.jpg
p_orders.png
reports.png
sales.png
stock.png
supp.png
<%@ Page Language="C#" MasterPageFile="~/IVN_MasterPage.master" AutoEventWireup="true" CodeFile="order_view.aspx.cs" Inherits="order_view" Title="Sales Order Management System" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table style="width: 855px; height: 594px">
        <tr>
            <td valign="top">
                <table __designer:mapid="34e" style="width: 375px">
                    <tr __designer:mapid="34f">
                        <td __designer:mapid="350" class="style16" style="width: 77px">
                            <asp:Label ID="Label4" runat="server" ForeColor="#663300" 
                                style="font-weight: 700" Text="Purchasing"></asp:Label>
                        </td>
                        <td __designer:mapid="352" class="style2" style="width: 13px">
                            ||</td>
                        <td __designer:mapid="353" class="style16" style="width: 89px">
                            <asp:LinkButton ID="LinkButton7" runat="server" Font-Underline="False" 
                                ForeColor="#CC0000" PostBackUrl="~/order_view.aspx" 
                                style="font-weight: 700">Order List</asp:LinkButton>
                        </td>
                        <td __designer:mapid="355" class="style2" style="width: 13px">
                            ||</td>
                        <td __designer:mapid="356" class="style15" style="width: 106px">
                            <asp:LinkButton ID="LinkButton8" runat="server" Font-Underline="False" 
                                ForeColor="#CC0000" PostBackUrl="~/order_entry.aspx" 
                                style="font-weight: 700">Create Order</asp:LinkButton>
                        </td>
                        <td __designer:mapid="358" class="style2" style="width: 13px">
                            ||</td>
                        <td __designer:mapid="359" class="style16" style="width: 85px">
                            <asp:LinkButton ID="LinkButton9" runat="server" Font-Underline="False" 
                                ForeColor="#CC0000" PostBackUrl="~/order_search.aspx" 
                                style="font-weight: 700">Search Order</asp:LinkButton>
                        </td>
                    </tr>
                </table>
                <br />
                <asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Size="Medium" 
                    Text="Order List"></asp:Label>
                <br />
                <br />
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                    DataKeyNames="order_no" DataSourceID="SqlDataSource1" Height="1px" 
                    onrowdatabound="GridView1_RowDataBound" Width="1180px">
                    <RowStyle VerticalAlign="Top" />
                    <Columns>
                        <asp:TemplateField HeaderText="&lt;&gt;">
                            <ItemTemplate>
                                <asp:LinkButton ID="LinkButton1" runat="server" Font-Bold="True" 
                                    Font-Size="X-Large" Font-Underline="False" ForeColor="#333300" 
                                    onclick="LinkButton1_Click" Text="+"></asp:LinkButton>
                                <asp:Panel ID="Panel1" runat="server" Visible="False" Width="32px">
                                    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
                                        BackColor="White" CaptionAlign="Top" DataKeyNames="order_detail_no" 
                                        DataSourceID="SqlDataSource2" Height="1px" Width="663px">
                                        <RowStyle BackColor="WhiteSmoke" />
                                        <Columns>
                                            <asp:BoundField DataField="order_no_fk" HeaderText="Order #" 
                                                SortExpression="order_no_fk" >
                                                <HeaderStyle HorizontalAlign="Left" />
                                                <ItemStyle Width="90px" />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="item_name" HeaderText="Item Name" >
                                                <HeaderStyle HorizontalAlign="Left" />
                                                <ItemStyle Width="160px" />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="quantity" HeaderText="Quantity" 
                                                SortExpression="quantity" >
                                                <HeaderStyle HorizontalAlign="Left" />
                                                <ItemStyle Width="70px" />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="unit_price" HeaderText="Unit Price" 
                                                SortExpression="unit_price" >
                                                <HeaderStyle HorizontalAlign="Left" />
                                                <ItemStyle Width="110px" />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="net_cost" HeaderText="Net Cost" 
                                                SortExpression="net_cost" >
                                                <HeaderStyle HorizontalAlign="Left" />
                                                <ItemStyle Width="110px" />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="order_status" HeaderText="Order Status" 
                                                SortExpression="order_status" >
                                                <HeaderStyle HorizontalAlign="Left" />
                                                <ItemStyle Width="130px" />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="description" HeaderText="Description" 
                                                SortExpression="description" >
                                                <HeaderStyle HorizontalAlign="Left" />
                                                <ItemStyle Width="260px" />
                                            </asp:BoundField>
                                        </Columns>
                                        <HeaderStyle BackColor="#FFFFCC" />
                                    </asp:GridView>
                                    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                                        ConnectionString="<%$ ConnectionStrings:IVN_sysConnectionString %>" 
                                        DeleteCommand="DELETE FROM [order_detail] WHERE [order_detail_no] = @order_detail_no" 
                                        InsertCommand="INSERT INTO [order_detail] ([order_no_fk], [item_name], [order_status], [description], [quantity], [unit_price], [net_cost]) VALUES (@order_no_fk, @item_name, @order_status, @description, @quantity, @unit_price, @net_cost)" 
                                        SelectCommand="SELECT [order_no_fk], [item_name], [order_status], [description], [quantity], [unit_price], [net_cost], [order_detail_no] FROM [order_detail] WHERE ([order_no_fk] = @order_no_fk)" 
                                        UpdateCommand="UPDATE [order_detail] SET [order_no_fk] = @order_no_fk, [item_name] = @item_name, [order_status] = @order_status, [description] = @description, [quantity] = @quantity, [unit_price] = @unit_price, [net_cost] = @net_cost WHERE [order_detail_no] = @order_detail_no">
                                        <SelectParameters>
                                            <asp:Parameter Name="order_no_fk" Type="String" />
                                        </SelectParameters>
                                        <DeleteParameters>
                                            <asp:Parameter Name="order_detail_no" Type="Decimal" />
                                        </DeleteParameters>
                                        <UpdateParameters>
                                            <asp:Parameter Name="order_no_fk" Type="String" />
                                            <asp:Parameter Name="item_name" Type="String" />
                                            <asp:Parameter Name="order_status" Type="String" />
                                            <asp:Parameter Name="description" Type="String" />
                                            <asp:Parameter Name="quantity" Type="Decimal" />
                                            <asp:Parameter Name="unit_price" Type="Decimal" />
                                            <asp:Parameter Name="net_cost" Type="Decimal" />
                                            <asp:Parameter Name="order_detail_no" Type="Decimal" />
                                        </UpdateParameters>
                                        <InsertParameters>
                                            <asp:Parameter Name="order_no_fk" Type="String" />
                                            <asp:Parameter Name="item_name" Type="String" />
                                            <asp:Parameter Name="order_status" Type="String" />
                                            <asp:Parameter Name="description" Type="String" />
                                            <asp:Parameter Name="quantity" Type="Decimal" />
                                            <asp:Parameter Name="unit_price" Type="Decimal" />
                                            <asp:Parameter Name="net_cost" Type="Decimal" />
                                        </InsertParameters>
                                    </asp:SqlDataSource>
                                </asp:Panel>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="order_no" HeaderText="Order #" ReadOnly="True" 
                            SortExpression="order_no" >
                            <HeaderStyle HorizontalAlign="Left" />
                            <ItemStyle Width="90px" HorizontalAlign="Left" />
                        </asp:BoundField>
                        <asp:BoundField DataField="supplier_ref" HeaderText="Supplier" 
                            SortExpression="supplier_ref" >
                            <HeaderStyle HorizontalAlign="Left" />
                            <ItemStyle Width="150px" HorizontalAlign="Left" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Expr1" HeaderText="Order Date" 
                            SortExpression="Expr1" >
                        <HeaderStyle HorizontalAlign="Center" />
                        <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="total_purchase" HeaderText="Total Purchase" 
                            SortExpression="total_purchase" >
                            <HeaderStyle HorizontalAlign="Right" />
                            <ItemStyle Width="120px" HorizontalAlign="Right" />
                        </asp:BoundField>
                        <asp:BoundField DataField="paid_amount" HeaderText="Paid Amount" 
                            SortExpression="paid_amount" >
                            <HeaderStyle HorizontalAlign="Right" />
                            <ItemStyle Width="120px" HorizontalAlign="Right" />
                        </asp:BoundField>
                        <asp:BoundField DataField="credit_amount" HeaderText="Credited Amount" 
                            SortExpression="credit_amount" >
                            <HeaderStyle HorizontalAlign="Right" />
                            <ItemStyle Width="120px" HorizontalAlign="Right" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Expr2" HeaderText="Due Date" 
                            SortExpression="Expr2" >
                        <HeaderStyle HorizontalAlign="Center" />
                        <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="payment_status" HeaderText="Payment Status" 
                            SortExpression="payment_status" >
                            <HeaderStyle HorizontalAlign="Center" />
                        <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="order_status_overall" 
                            HeaderText="Order Status" SortExpression="order_status_overall" >
                            <HeaderStyle HorizontalAlign="Left" />
                        </asp:BoundField>
                    </Columns>
                    <HeaderStyle BackColor="#FFFFCC" />
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:IVN_sysConnectionString %>" 
                    DeleteCommand="DELETE FROM [orders] WHERE [order_no] = @order_no" 
                    InsertCommand="INSERT INTO [orders] ([order_no], [order_date], [supplier_ref], [prepared_by], [credit_days], [credit_due_date], [order_status_overall], [full_payment_made], [payment_status], [credit_amount], [paid_amount], [total_purchase]) VALUES (@order_no, @order_date, @supplier_ref, @prepared_by, @credit_days, @credit_due_date, @order_status_overall, @full_payment_made, @payment_status, @credit_amount, @paid_amount, @total_purchase)" 
                    SelectCommand="SELECT order_no, CONVERT (VARCHAR, order_date, 101) AS Expr1, supplier_ref, prepared_by, credit_days, CONVERT (VARCHAR, credit_due_date, 101) AS Expr2, order_status_overall, CONVERT (VARCHAR, full_payment_made, 101) AS Expr3, payment_status, credit_amount, paid_amount, total_purchase FROM orders ORDER BY Expr1 DESC" 
                    
                    
                    
                    UpdateCommand="UPDATE [orders] SET [order_date] = @order_date, [supplier_ref] = @supplier_ref, [prepared_by] = @prepared_by, [credit_days] = @credit_days, [credit_due_date] = @credit_due_date, [order_status_overall] = @order_status_overall, [full_payment_made] = @full_payment_made, [payment_status] = @payment_status, [credit_amount] = @credit_amount, [paid_amount] = @paid_amount, [total_purchase] = @total_purchase WHERE [order_no] = @order_no">
                    <DeleteParameters>
                        <asp:Parameter Name="order_no" Type="String" />
                    </DeleteParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="order_date" Type="DateTime" />
                        <asp:Parameter Name="supplier_ref" Type="String" />
                        <asp:Parameter Name="prepared_by" Type="String" />
                        <asp:Parameter Name="credit_days" Type="Decimal" />
                        <asp:Parameter Name="credit_due_date" Type="DateTime" />
                        <asp:Parameter Name="order_status_overall" Type="String" />
                        <asp:Parameter Name="full_payment_made" Type="DateTime" />
                        <asp:Parameter Name="payment_status" Type="String" />
                        <asp:Parameter Name="credit_amount" Type="Decimal" />
                        <asp:Parameter Name="paid_amount" Type="Decimal" />
                        <asp:Parameter Name="total_purchase" Type="Decimal" />
                        <asp:Parameter Name="order_no" Type="String" />
                    </UpdateParameters>
                    <InsertParameters>
                        <asp:Parameter Name="order_no" Type="String" />
                        <asp:Parameter Name="order_date" Type="DateTime" />
                        <asp:Parameter Name="supplier_ref" Type="String" />
                        <asp:Parameter Name="prepared_by" Type="String" />
                        <asp:Parameter Name="credit_days" Type="Decimal" />
                        <asp:Parameter Name="credit_due_date" Type="DateTime" />
                        <asp:Parameter Name="order_status_overall" Type="String" />
                        <asp:Parameter Name="full_payment_made" Type="DateTime" />
                        <asp:Parameter Name="payment_status" Type="String" />
                        <asp:Parameter Name="credit_amount" Type="Decimal" />
                        <asp:Parameter Name="paid_amount" Type="Decimal" />
                        <asp:Parameter Name="total_purchase" Type="Decimal" />
                    </InsertParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
    </table>
</asp:Content>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

fawadhq
Software Developer
Saudi Arabia Saudi Arabia
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411023.1 | Last Updated 19 Jul 2009
Article Copyright 2009 by fawadhq
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid