好的,我写了一个2表单应用程序。第一页有一系列下拉列表和gridview。客户从下拉列表中选择产品,它在gridview中显示详细信息。然后我有3个文本框,因此用户可以输入他们想要的数量,他们的名字和地址。底部是创建订单按钮,该按钮当前重定向到下一页。
然而,在那个页面上,我应该创建客户并在屏幕上下订单,它应该说订单是成功创建的,订单号,我应该使用一个程序为此目的提交给我的称为CreateOrder。
但是,我需要知道我是否实际创建了客户并通过单击第一页上的按钮进行订购,然后允许订单号显示在第二页上,或者我是否在第二页上创建了客户,并显示订单号?这是第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>
答案 0 :(得分:0)
您可以将按钮更改为服务器端按钮
然后向其添加服务器端事件。