I have a page (Order.aspx
) which displays an order which has a specific FileNo
, below I call this page from my (Default.aspx
):
LinkButton clickedButton = (LinkButton)sender;
Session["FileNo"] = clickedButton.Text;
Response.Redirect("~/Order.aspx");
In this order page there is a gridview control with the following sqldatasource, the below Datasource was successfully working and updating the database, but suddenly it started to update the database with null FileNo. I don't understand when does my Session["FileNo"]
gets cleared. I can provide any extra code requested.
<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>
Other than select parameters, all the other parameters should include FileNo as SessionParameter, Session["FileNo"] is not cleared, it was not used.