I have a web project in which a 'Cart.aspx page'. In this page i stored datatable value in session variable like below:
" Session["Buyitem"]=dt; . Now i want to use this session variable value in second page 'PaymentGateway.aspx' page like below:
- DataTable dt;
- dt = (DataTable)Session["Buyitem"];
- for (int i = 0; i <= dt.Rows.Count - 1; i++)
- {
- con = new SqlConnection(cons);
- con.Open();
- string sql = ("Insert into OrderDetails(OrderID,ProductName,ProductImage,Price,CustomerName,BillingAddress,OrderDate,OrderStatus)values('" + Session["OrderID"] + "','" + dt.Rows[i]["Product_Name"] + "','" + dt.Rows[i]["ProdImage"] + "','" + dt.Rows[i]["ProdPrice"] + "','" + Session["CstmrName"] + "','" + Session["BillingAddress"] + "','" + Session["Orderdate"] + "','Pending')");
- cmd = new SqlCommand(sql, con);
- cmd.ExecuteNonQuery();
- con.Close();
- Session["Buyitem"] = null;
- }
but i am getting "System.NullReferenceException: 'Object reference not set to an instance of an object.'
dt was null."
Now i want to clear something:
By Cart.aspx page we redirected to Paytm gateway page and on successfull payment then redirected to PaymentGateway.aspx page .
Cart.aspx page------------------->Paytm Gateway Page-------------------------> PaymentGateway.aspx
Plz Help..
Thanks