locked
Need very very urgent help..... from grid to detail RRS feed

  • Question

  • User764185445 posted

    Hi
    I guess i was working too much that is why i feel blank inside my head and need some help.

    I have a page (Catalogue) With a RADGRID where the user will use it to look through all the items, then by clicking on the Select Item he will go to Order Page, in this order page he will see the details for the item selected (at the top of the page) and a form to fill to submit the order.

    - The Grid is using a table (Items).
    - The Detail View is using the same table (Items) to display the info about the selected item (through a SqlDataSource on the Order Page page).
    - There is another SqlDataSource (from the Orders table) on the Order Page.
    - The form on the Order Page right now is suppose to insert the Data into the Orders Table.
    - Order table and Items Table are related with the Column ItemID.

    Now
    - Everything is working fine between the Grid view(catalogue page) and the Detail View (on the order page), but what i need is:

    + When the user click Save the Data inserted into the Order Table with the ItemID (for the selected Item) and direct the user to another page (OrderListPage).

    + When the user Click Save and More the data inserted into the Order table(database) and direct the user back to the Catalogue Page.

    + When the user Click Cancel it direct the user back to the Catalogue page.


    (i tried that but nothing goes to database so i am sure i am missing something plus i do not know how to redirect to page after insertion)
    Thanks in Advance for any help

    I have screen shots to explain the process but do not know how to attach 'em in here


    Thanks in advance

    Friday, March 19, 2010 6:10 PM

All replies

  • User-1687464726 posted

    Dear Friend ,

    I feel you need to save the selected item in database , the details of this

    item can also be viewed in other window.Kindly correct me if m wrong about

    this interpretation of your problem. In the simplest way you can read the items of

    gridview in loop by finding the control which takes the item Id while binding

     and take the ID of item to save in database.

    Regards,

    Mandeep

     

    Saturday, March 20, 2010 1:25 AM
  • User1297671903 posted

    Please post your code here, which would help us to find if anything is missing or not. 

    Saturday, March 20, 2010 2:17 AM
  • User764185445 posted

    Sorry if i did not explain it well but i have attached some images to explain it well. you can see it in here

    http://img709.imageshack.us/img709/1965/orderk.jpg

    http://img716.imageshack.us/img716/871/databaseshot.jpg

    http://img87.imageshack.us/img87/6608/catalogue.jpg


    - for now the user can select the item and the order page can show the details of this item through Detail View (using ItemID).

    Here is the code for the Order Page:

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="AddOrder.aspx.vb" Inherits="Orders_AddOrder" %>

    <!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>Add Order</title>
        <script type="text/javascript">
        
          function pageLoad() {
          }
        
        </script>
        <style type="text/css">
            .style1
            {
                width: 100%;
            }
            .style2
            {
                width: 742px;
            }
            .style3
            {
                text-align: left;
                width: 275px;
            }
            .style4
            {
                font-weight: bold;
                color: #800000;
                text-align: right;
                width: 128px;
            }
            .style5
            {
                font-weight: bold;
                text-align: right;
                width: 275px;
            }
            .style6
            {
                font-weight: bold;
                text-align: right;
                width: 128px;
            }
            .style8
            {
                text-align: right;
                font-weight: bold;
            }
            .style9
            {
                text-align: left;
                width: 0;
            }
            .style10
            {
                width: 301px;
            }
            </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <table>
                <tr>
                    <td colspan="2">
                        Add Order</td>
                </tr>
                <tr>
                    <td colspan="2">
                        <table>
                            <tr>
                                <td width="200">
                                    Item Details</td>
                                <td>
                                    <hr/>
                                </td>
                                <td>
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td width="200">
                                    &nbsp;</td>
                                <td bgcolor="Maroon">
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td width="200">
                                    &nbsp;</td>
                                <td bgcolor="Maroon">
                                    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
                                        CellPadding="4" DataKeyNames="ItemID" DataSourceID="SqlDataSource2"
                                        ForeColor="#333333" GridLines="None" Height="50px" Width="497px">
                                        <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                                        <CommandRowStyle BackColor="#C5BBAF" Font-Bold="True" />
                                        <RowStyle BackColor="#E3EAEB" />
                                        <FieldHeaderStyle BackColor="#D0D0D0" Font-Bold="True" />
                                        <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                                        <Fields>
                                            <asp:BoundField DataField="ItemID" HeaderText="ID" InsertVisible="False"
                                                ReadOnly="True" SortExpression="ItemID" >
                                            <HeaderStyle HorizontalAlign="Right" />
                                            <ItemStyle HorizontalAlign="Left" />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="DivisionName" HeaderText="Division"
                                                SortExpression="DivisionName" >
                                            <HeaderStyle HorizontalAlign="Right" />
                                            <ItemStyle HorizontalAlign="Left" />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="CategoryName" HeaderText="Category"
                                                SortExpression="CategoryName" >
                                            <HeaderStyle HorizontalAlign="Right" />
                                            <ItemStyle HorizontalAlign="Left" />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="TypeName" HeaderText="Item Type"
                                                SortExpression="TypeName" >
                                            <HeaderStyle HorizontalAlign="Right" />
                                            <ItemStyle HorizontalAlign="Left" />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="CodeName" HeaderText="Code"
                                                SortExpression="CodeName" >
                                            <HeaderStyle HorizontalAlign="Right" />
                                            <ItemStyle HorizontalAlign="Left" />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="FullCode" HeaderText="Full Code"
                                                SortExpression="FullCode" >
                                            <HeaderStyle HorizontalAlign="Right" />
                                            <ItemStyle HorizontalAlign="Left" />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="SectionName" HeaderText="Section"
                                                SortExpression="SectionName" >
                                            <HeaderStyle HorizontalAlign="Right" />
                                            <ItemStyle HorizontalAlign="Left" />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="VersionName" HeaderText="Version"
                                                SortExpression="VersionName" >
                                            <HeaderStyle HorizontalAlign="Right" />
                                            <ItemStyle HorizontalAlign="Left" />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="PagesNumber" HeaderText="# of Pages"
                                                SortExpression="PagesNumber">
                                            <HeaderStyle HorizontalAlign="Right" />
                                            <ItemStyle HorizontalAlign="Left" />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="ReleaseDate" HeaderText="Release Date"
                                                SortExpression="ReleaseDate" DataFormatString="{0:d}">
                                            <HeaderStyle HorizontalAlign="Right" />
                                            <ItemStyle HorizontalAlign="Left" />
                                            </asp:BoundField>
                                            <asp:CheckBoxField DataField="Discontinued" HeaderText="Discontinued"
                                                SortExpression="Discontinued" >
                                            <HeaderStyle HorizontalAlign="Right" />
                                            <ItemStyle HorizontalAlign="Left" />
                                            </asp:CheckBoxField>
                                            <asp:BoundField DataField="ItemDescription" HeaderText="Item Description"
                                                SortExpression="ItemDescription">
                                            <HeaderStyle HorizontalAlign="Right" />
                                            <ItemStyle HorizontalAlign="Left" />
                                            </asp:BoundField>
                                        </Fields>
                                        <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                                        <EditRowStyle BackColor="#7C6F57" />
                                        <AlternatingRowStyle BackColor="White" />
                                    </asp:DetailsView>
                                </td>
                                <td>
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td width="200">
                                    &nbsp;</td>
                                <td bgcolor="Maroon">
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td bgcolor="Black" width="300">
                                    &nbsp;</td>
                    <td bgcolor="#999999">
                                    &nbsp;</td>
                </tr>
                <tr>
                    <td colspan="2">
                        <table border="0">
                            <tr>
                                <td width="300">
                                    &nbsp;</td>
                                <td width="200">
                                    Order Number</td>
                                <td width="200">
                                    <asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval( Container, "DataItem.OrderID" ) %>'></asp:Label>
                                </td>
                                <td width="200">
                                    <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
                                </td>
                                <td width="200">
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td width="300">
                                    &nbsp;</td>
                                <td width="200">
                                    Order Date</td>
                                <td width="200">
                                    <asp:Label ID="Label2" runat="server" Text='<%# DataBinder.Eval( Container, "DataItem.OrderDate" ) %>'></asp:Label>
                                </td>
                                <td width="200">
                                    &nbsp;</td>
                                <td width="200">
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td width="300">
                                    &nbsp;</td>
                                <td width="200">
                                    &nbsp;</td>
                                <td width="200">
                                    &nbsp;</td>
                                <td width="200">
                                    &nbsp;</td>
                                <td width="200">
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td width="300">
                                    &nbsp;</td>
                                <td width="200">
                                    Quantuty Required</td>
                                <td width="200">
                                    <telerik:RadNumericTextBox ID="RadNumericTextBox1" Runat="server"
                                        Culture="English (United Kingdom)" ShowSpinButtons="True" Value="0"
                                        Width="100px">
                                        <NumberFormat DecimalDigits="0" />
                                    </telerik:RadNumericTextBox>
                                </td>
                                <td width="200">
                                    Delivery Place</td>
                                <td width="200">
                                    <telerik:RadComboBox ID="RadComboBox1" Runat="server"
                                        DataSourceID="SqlDataSource4" DataTextField="WarehouseName"
                                        DataValueField="WarehouseID">
                                    </telerik:RadComboBox>
                                </td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td width="300">
                                    &nbsp;</td>
                                <td width="200">
                                    Date Required</td>
                                <td width="200">
                                    <telerik:RadDatePicker ID="RadDatePicker1" Runat="server"
                                        Culture="English (United Kingdom)" SelectedDate="2010-03-17" Width="180px">
    <Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x"></Calendar>

    <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>

    <DateInput DisplayDateFormat="dd/MM/yyyy" DateFormat="dd/MM/yyyy" SelectedDate="2010-03-17"></DateInput>
                                    </telerik:RadDatePicker>
                                </td>
                                <td width="200">
                                    Submit Order</td>
                                <td width="200">
                                    <asp:CheckBox ID="CheckBox1" runat="server" />
                                </td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td width="300">
                                    &nbsp;</td>
                                <td width="200">
                                    Order Comment</td>
                                <td colspan="2" width="200">
                                    <asp:TextBox id="TextBox4" runat="server" Width="400px"
                    Height="75px" TextMode="MultiLine"></asp:textbox>
                                </td>
                                <td width="200">
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td width="300">
                                    &nbsp;</td>
                                <td width="200">
                                    &nbsp;</td>
                                <td>
                                    <asp:Button ID="Button1" runat="server" Text="Save" Width="120px"
                                        CommandName="Submit" />
                                </td>
                                <td width="200" style="width: 100px">
                                    <asp:Button ID="btnCancel" runat="server" Text="Save and More" Width="150px" CausesValidation="false"
                            CommandName="Cancel"></asp:Button>
                                </td>
                                <td width="200">
                                    <asp:Button ID="btnCancel0" runat="server" Text="Cancel" Width="150px" CausesValidation="false"
                            CommandName="Cancel"></asp:Button>
                                </td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td bgcolor="Black" width="300">
                        &nbsp;</td>
                    <td bgcolor="#999999">
                        &nbsp;</td>
                </tr>
            </table>
            <asp:ScriptManager ID="ScriptManager1" runat="server" />
        </div>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server"
            ConnectionString="<%$ ConnectionStrings:OrderSystemConn %>"
            
            SelectCommand="SELECT Item.ItemID, Division.DivisionName, Category.CategoryName, Type.TypeName, Code.CodeName, Item.FullCode, Section.SectionName, Version.VersionName, Item.PagesNumber, Item.ReleaseDate, Item.Discontinued, Item.ItemDescription FROM Item INNER JOIN Division ON Item.DivisionID = Division.DivisionID INNER JOIN Category ON Item.CategoryID = Category.CategoryID INNER JOIN Code ON Item.CodeID = Code.CodeID INNER JOIN Section ON Item.SectionID = Section.SectionID INNER JOIN Type ON Item.TypeID = Type.TypeID INNER JOIN Version ON Item.VersionID = Version.VersionID WHERE (Item.ItemID = @ItemID)">
            <SelectParameters>
                <asp:QueryStringParameter DefaultValue="1" Name="ItemID"
                    QueryStringField="ItemID" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource3" runat="server"
            ConnectionString="<%$ ConnectionStrings:OrderSystemConn %>"
            
            SelectCommand="SELECT [OrderID], [OrderDate], [Quantity], [DateRequired], [OrderComment], [OrderSubmit], [ItemID], [WarehouseID] FROM [Orders]"
            DeleteCommand="DELETE FROM [Orders] WHERE [OrderID] = @OrderID"
            InsertCommand="INSERT INTO [Orders] ([OrderDate], [Quantity], [DateRequired], [OrderComment], [OrderSubmit], [ItemID], [WarehouseID]) VALUES (@OrderDate, @Quantity, @DateRequired, @OrderComment, @OrderSubmit, @ItemID, @WarehouseID)"
            UpdateCommand="UPDATE [Orders] SET [OrderDate] = @OrderDate, [Quantity] = @Quantity, [DateRequired] = @DateRequired, [OrderComment] = @OrderComment, [OrderSubmit] = @OrderSubmit, [ItemID] = @ItemID, [WarehouseID] = @WarehouseID WHERE [OrderID] = @OrderID">
            
            
            <DeleteParameters>
                <asp:Parameter Name="OrderID" />
            </DeleteParameters>       
            
            <InsertParameters>
                <asp:Parameter Name="OrderDate" Type="DateTime" />
                <asp:Parameter Name="Quantity" Type="Int32" />
                <asp:Parameter Name="DateRequired" Type="DateTime" />
                <asp:Parameter Name="OrderComment" Type="String" />
                <asp:Parameter Name="OrderSubmit" Type="Boolean" />
                <asp:Parameter Name="ItemID" Type="Int32" />
                <asp:Parameter Name="WarehouseID" Type="Int32" />
            </InsertParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource4" runat="server"
            ConnectionString="<%$ ConnectionStrings:OrderSystemConn %>"
            
            SelectCommand="SELECT [WarehouseID], [WarehouseName] FROM [Warehouse] ORDER BY [WarehouseName]">
        </asp:SqlDataSource>
        </form>
    </body>
    </html>

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------

    Again Thanks for any help

    Saturday, March 20, 2010 9:57 AM