1 Replies - 5067 Views - Last Post: 04 June 2014 - 02:44 AM

#1 BasementArtScott  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 49
  • Joined: 11-July 09

Submit Button/New Customer with Stored Procedure

Posted 23 February 2014 - 12:20 PM

OK, I've written a 2 form application. The first page has a series of dropdownslist and a gridview. The customer selects the product from the dropdownlist, it appears with details in the gridview. I then have 3 textboxes so the user can input the quantity they desire, their name, and address. At the bottom is a create order button, which currently redirects to the next page.

On that page, however, I'm supposed to have the customer created and the order placed on the screen it's supposed to say that the order was created successfully, and the order number, and I'm supposed to use a procedure called CreateOrder that was submitted to me for this purpose.

However, I need to know do I actually create the customer and order with the button click on the first page, and then allow the order number to display on the second, or would I have the customer created on the second page, and the order number displayed? Here is the code for page 1.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"     Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

</div>
<div style="height: 182px">
Category: <asp:DropDownList ID="ddlCategory"
runat="server" DataSourceID="SqlDataSource1" DataTextField="CategoryName"   
DataValueField="CategoryId" AutoPostBack="True"/>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DeveloperInterviewConnectionString %>" SelectCommand="CategoryListing"   SelectCommandType="StoredProcedure"></asp:SqlDataSource>
<br/>
Product: <asp:DropDownList ID="ddlProduct"
runat="server" DataSourceID="SqlDataSource2" DataTextField="ProductName"   

DataValueField="ProductId" AutoPostBack="True"/>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ 

ConnectionStrings:DeveloperInterviewConnectionString %>"   SelectCommand="CategoryProducts" SelectCommandType="StoredProcedure">
   <SelectParameters>
<asp:ControlParameter ControlID="ddlCategory" Name="CategoryId"     
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"  DataKeyNames="ProductId" DataSourceID="SqlDataSource3" Width="105px">
<Columns>
<asp:BoundField DataField="ProductId" HeaderText="ProductId" InsertVisible="False"  ReadOnly="True" SortExpression="ProductId" />
<asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
 <asp:BoundField DataField="ProductDescription" HeaderText="ProductDescription" SortExpression="ProductDescription" />
 <asp:BoundField DataField="QuantityInStock" HeaderText="QuantityInStock" SortExpression="QuantityInStock" />
            </Columns>
        </asp:GridView>
        <br/>
        <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:DeveloperInterviewConnectionString %>" SelectCommand="SELECT     [ProductId], [ProductName], [ProductDescription], [QuantityInStock] FROM [Product] WHERE  ([ProductId] = @ProductId)">
            <SelectParameters>
                <asp:ControlParameter ControlID="ddlProduct" Name="ProductId" PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
    <p>
        <asp:Label ID="Label1" runat="server" Text="Quantity to Order"></asp:Label>
        <asp:TextBox ID="QuantityOrderTB" runat="server" Width="223px"></asp:TextBox>
    </p>
    <p>
        <asp:Label ID="Label2" runat="server" Text="Customer Name"></asp:Label>
        <asp:TextBox ID="CustomerNameTB" runat="server" Width="223px"> </asp:TextBox>
    </p>
    <p>
        <asp:Label ID="Label3" runat="server" Text="Customer Address"></asp:Label>
        <asp:TextBox ID="CustomerAddressTB" runat="server" Height="61px" Width="260px">    </asp:TextBox>
        </p>
 <br />
       <input type="button" value="Create Order"
 onclick="location.href = 'Confirmation.aspx';">
</div>
</form>
</body>
</html>



Is This A Good Question/Topic? 0
  • +

Replies To: Submit Button/New Customer with Stored Procedure

#2 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 975
  • Joined: 09-May 09

Re: Submit Button/New Customer with Stored Procedure

Posted 04 June 2014 - 02:44 AM

Install SQL Management studio, select your database, expand the tree, right click on programmability and click new stored procedure

Check out my post from yesterday, I was doing the same thing with stored procedures, all the code is there including the stored procedure

http://www.dreaminco...t-time-in-loop/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1