locked
Newbie trying to find her feet RRS feed

  • Question

  • User-760580202 posted

    hi  sorry if this has been dealt with somewhere on the site but I cant see it.

    need to do a e-commerce web sitein ASP.net and have got this far and am struggling to find what I need to carry on.

    Any help with links to tuts etc much appreciated.  The attached code needs to become a order confirmation page for the user to confirm or alter as necessary - have some knowledge on how to add, remove and submit on the page but unsure how to do joins between two pages to display all the order info etc.   Cant figure out how to get the page to only show the user their own order details only as it is bringing up all existing orders as it stands.

    Once again sorry for my stupidity but have hit a wall

    <%@ Page Language="VB" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">

        
            Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
            
            Dim strDatabaseNameAndLocation As String
            strDatabaseNameAndLocation = Server.MapPath("Orders.mdb")
            Dim strSQLCommand As String
            strSQLCommand = "SELECT Customers.* FROM Customers ORDER BY Customers.UserID DESC;"
            Dim objOleDbConnection As System.Data.OleDb.OleDbConnection
            objOleDbConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0; Data Source=" & strDatabaseNameAndLocation)
            objOleDbConnection .Open()
            Dim objOleDbCommand As System.Data.OleDb.OleDbCommand
            objOleDbCommand = New System.Data.OleDb.OleDbCommand(strSQLCommand, objOleDbConnection)
            Dim objOleDbDataReader As System.Data.OleDb.OleDbDataReader
            objOleDbDataReader = objOleDbCommand.ExecuteReader()
            Dim datDataTable As System.Data.DataTable
            datDataTable = New System.Data.DataTable()
            datDataTable.Load(objOleDbDataReader)
            gdvOrdersCustomers.DataSource = datDataTable
            gdvOrdersCustomers.DataBind()
            objOleDbConnection .Close()

       
        End Sub

    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">

    <head runat="server">
    <title>B00227764 Order Confirmation</title>
    </head>

    <body>

    <form id="webform" runat="server">
        <div>
            <asp:GridView ID="gdvOrdersCustomers" runat="server"
                AutoGenerateColumns="False">
                <Columns>
                    <asp:BoundField DataField="FullName" HeaderText="FullName"
                        SortExpression="FullName" />
                    <asp:BoundField DataField="Address" HeaderText="Address"
                        SortExpression="Address" />
                    <asp:BoundField DataField="Town" HeaderText="Town"
                        SortExpression="Town" />
                    <asp:BoundField DataField="County" HeaderText="County"
                        SortExpression="County" />
                    <asp:BoundField DataField="Postcode" HeaderText="Postcode"
                        SortExpression="Postcode" />
                    <asp:BoundField DataField="Country" HeaderText="Country"
                        SortExpression="Country" />
                    <asp:BoundField DataField="OrderAmount" HeaderText="Order Value"
                        SortExpression="OrderAmount" />
                    <asp:BoundField DataField="CardNumber" HeaderText="Card Number"
                        SortExpression="CardNumber" />
                    <asp:BoundField DataField="CardName" HeaderText="CardName"
                        SortExpression="CardName" />
                    <asp:BoundField DataField="CardExpires" HeaderText="Card Expiry Date"
                        SortExpression="CardExpires" />
                    <asp:BoundField DataField="CardSecurityCode" HeaderText="Card Security Code"
                        SortExpression="CardSecurityCode" />
                    <asp:BoundField DataField="BasketID" HeaderText="Basket ID"
                        SortExpression="BasketID" />
                    <asp:BoundField DataField="Email" HeaderText="Email"
                        SortExpression="Email" />
                   </Columns>
            </asp:GridView>
        </div>
    </form>

    </body>

    </html>

    Tuesday, July 10, 2012 9:38 AM

Answers

All replies

  • User1690870723 posted

    Couple things I noticed..

    So you need to pass the data from one page to another..

    You could use session variables 

    (ex)

    http://stackoverflow.com/questions/5230254/how-to-pass-objects-not-values-between-pages-in-asp-net-c

    Or aa even simpler way is to create a table in your database where you just input temporary customer cart orders.

    So do an insert when the user is ready to switch pages, get the return id of that table and pass the temp table id in the new url query string 

    (ex)

    http://www.codeproject.com/Articles/5876/Passing-variables-between-pages-using-QueryString

    string cartOrderId=Request.QueryString["cartOrderId"];

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 10, 2012 11:05 AM
  • User3866881 posted

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
            
            Dim strDatabaseNameAndLocation As String
            strDatabaseNameAndLocation = Server.MapPath("Orders.mdb")
            Dim strSQLCommand As String
            strSQLCommand = "SELECT Customers.* FROM Customers ORDER BY Customers.UserID DESC;"
            Dim objOleDbConnection As System.Data.OleDb.OleDbConnection
            objOleDbConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0; Data Source=" & strDatabaseNameAndLocation)
            objOleDbConnection .Open()
            Dim objOleDbCommand As System.Data.OleDb.OleDbCommand
            objOleDbCommand = New System.Data.OleDb.OleDbCommand(strSQLCommand, objOleDbConnection)
            Dim objOleDbDataReader As System.Data.OleDb.OleDbDataReader
            objOleDbDataReader = objOleDbCommand.ExecuteReader()
            Dim datDataTable As System.Data.DataTable
            datDataTable = New System.Data.DataTable()
            datDataTable.Load(objOleDbDataReader)
            gdvOrdersCustomers.DataSource = datDataTable
            gdvOrdersCustomers.DataBind()
            objOleDbConnection .Close()
         End Sub

    My addition——

    Your codes look nice except it that everytime when your press the key "Submit", it will render the whole page and re-databind to the GridView from db to aspx page again and again……This isn't good;I think you can try to add the fully codes into If (Not IsPostBack)……End If block in the Page_Load event。

    Regaurds!

    Wednesday, July 11, 2012 9:23 PM