我有一个页面 ( Order.aspx
) 显示具有特定 的订单FileNo
,下面我从我的 ( Default.aspx
) 调用此页面:
LinkButton clickedButton = (LinkButton)sender;
Session["FileNo"] = clickedButton.Text;
Response.Redirect("~/Order.aspx");
在此订单页面中有一个带有以下 sqldatasource 的 gridview 控件,以下 Datasource 已成功运行并更新数据库,但突然开始使用 null FileNo 更新数据库。我不明白我什么时候Session["FileNo"]
被清除。我可以提供任何要求的额外代码。
<asp:SqlDataSource ID="sds_OrderDetail" OnSelected="sds_OrderDetail_Selected" runat="server"
ConnectionString="<%$ ConnectionStrings:MyDbConn %>" DeleteCommand="DELETE FROM [OrderDetail] WHERE [RowNo] = @RowNo"
InsertCommand="INSERT INTO [OrderDetail] ([FileNo], [PONumber], [MaterialCode], [MaterialDescription], [MaterialCategory], [UnitOfMeasure], [Quantity], [ContainerType], [LoadingDate]) VALUES (@FileNo, @PONumber, @MaterialCode, @MaterialDescription, @MaterialCategory, @UnitOfMeasure, @Quantity, @ContainerType, @LoadingDate)"
SelectCommand="SELECT * FROM [OrderDetail] WHERE ([FileNo] = @FileNo)" UpdateCommand="UPDATE [OrderDetail] SET [FileNo] = @FileNo, [PONumber] = @PONumber, [MaterialCode] = @MaterialCode, [MaterialDescription] = @MaterialDescription, [MaterialCategory] = @MaterialCategory, [UnitOfMeasure] = @UnitOfMeasure, [Quantity] = @Quantity, [ContainerType] = @ContainerType, [LoadingDate] = @LoadingDate WHERE [RowNo] = @RowNo">
<SelectParameters>
<asp:SessionParameter DefaultValue="-1" Name="FileNo" SessionField="FileNo" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="RowNo" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="FileNo" Type="Int32" />
<asp:Parameter Name="PONumber" Type="String" />
<asp:Parameter Name="MaterialCode" Type="String" />
<asp:Parameter Name="MaterialDescription" Type="String" />
<asp:Parameter Name="MaterialCategory" Type="String" />
<asp:Parameter Name="UnitOfMeasure" Type="String" />
<asp:Parameter Name="Quantity" Type="Int32" />
<asp:Parameter Name="ContainerType" Type="String" />
<asp:Parameter Name="LoadingDate" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="FileNo" Type="Int32" />
<asp:Parameter Name="PONumber" Type="String" />
<asp:Parameter Name="MaterialCode" Type="String" />
<asp:Parameter Name="MaterialDescription" Type="String" />
<asp:Parameter Name="MaterialCategory" Type="String" />
<asp:Parameter Name="UnitOfMeasure" Type="String" />
<asp:Parameter Name="Quantity" Type="Int32" />
<asp:Parameter Name="ContainerType" Type="String" />
<asp:Parameter Name="LoadingDate" Type="String" />
<asp:Parameter Name="RowNo" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>