使用 asp.net 中的 ID 查看数据
view data using ID in asp.net
我想使用
查看另一个页面
Response.redirect
但同时考虑 customerID。这是我的按钮代码:
protected void btnPlaceOrder_Click(object sender, EventArgs e)
{
string productids = string.Empty;
DataTable dt;
if (Session["MyCart"] != null)
{
dt = (DataTable)Session["MyCart"];
decimal totalPrice, totalProducts;
bool totalPriceConversionResult = decimal.TryParse(txtTotalPrice.Text, out totalPrice), totalProductsConversionResult = decimal.TryParse(txtTotalProducts.Text, out totalProducts);
ShoppingCart k = new ShoppingCart()
{
CustomerName = txtCustomerName.Text,
CustomerEmailID = txtCustomerEmailID.Text,
CustomerAddress = txtCustomerAddress.Text,
CustomerPhoneNo = txtCustomerPhoneNo.Text,
TotalProducts = totalProductsConversionResult ? Convert.ToInt32(totalProducts) : 0,
TotalPrice = totalPriceConversionResult ? Convert.ToInt32(totalPrice) : 0,
ProductList = productids,
PaymentMethod = rblPaymentMethod.SelectedItem.Text
};
DataTable dtResult = k.SaveCustomerDetails();
for (int i = 0; i < dt.Rows.Count; i++) // loop on how many products are added by the user
{
ShoppingCart SaveProducts = new ShoppingCart()
{
CustomerID = Convert.ToInt32(dtResult.Rows[0][0]),
ProductID = Convert.ToInt32(dt.Rows[i]["ProductID"]),
TotalProducts = Convert.ToInt32(dt.Rows[i]["ProductQuantity"]),
};
SaveProducts.SaveCustomerProducts();
}
Response.Redirect("Admin/OrderDetails.aspx?Id={0}");
它的作用是获取所有用户输入,然后最后,我想向用户显示 his/her 订单摘要。如您所见,我正在尝试使用 Response.Redirect.
问题是我想在使用
时使用当前的客户 ID
Response.Redirect("Admin/OrderDetails.aspx?Id={0}");
有什么技巧吗?
您已经 CustomerID
。在用该值
重定向之前替换 {0}
var customerId = Convert.ToInt32(dtResult.Rows[0][0]);
Response.Redirect(String.Format("Admin/OrderDetails.aspx?Id={0}", customerId.ToString()));
我想使用
查看另一个页面Response.redirect
但同时考虑 customerID。这是我的按钮代码:
protected void btnPlaceOrder_Click(object sender, EventArgs e)
{
string productids = string.Empty;
DataTable dt;
if (Session["MyCart"] != null)
{
dt = (DataTable)Session["MyCart"];
decimal totalPrice, totalProducts;
bool totalPriceConversionResult = decimal.TryParse(txtTotalPrice.Text, out totalPrice), totalProductsConversionResult = decimal.TryParse(txtTotalProducts.Text, out totalProducts);
ShoppingCart k = new ShoppingCart()
{
CustomerName = txtCustomerName.Text,
CustomerEmailID = txtCustomerEmailID.Text,
CustomerAddress = txtCustomerAddress.Text,
CustomerPhoneNo = txtCustomerPhoneNo.Text,
TotalProducts = totalProductsConversionResult ? Convert.ToInt32(totalProducts) : 0,
TotalPrice = totalPriceConversionResult ? Convert.ToInt32(totalPrice) : 0,
ProductList = productids,
PaymentMethod = rblPaymentMethod.SelectedItem.Text
};
DataTable dtResult = k.SaveCustomerDetails();
for (int i = 0; i < dt.Rows.Count; i++) // loop on how many products are added by the user
{
ShoppingCart SaveProducts = new ShoppingCart()
{
CustomerID = Convert.ToInt32(dtResult.Rows[0][0]),
ProductID = Convert.ToInt32(dt.Rows[i]["ProductID"]),
TotalProducts = Convert.ToInt32(dt.Rows[i]["ProductQuantity"]),
};
SaveProducts.SaveCustomerProducts();
}
Response.Redirect("Admin/OrderDetails.aspx?Id={0}");
它的作用是获取所有用户输入,然后最后,我想向用户显示 his/her 订单摘要。如您所见,我正在尝试使用 Response.Redirect.
问题是我想在使用
时使用当前的客户 IDResponse.Redirect("Admin/OrderDetails.aspx?Id={0}");
有什么技巧吗?
您已经 CustomerID
。在用该值
{0}
var customerId = Convert.ToInt32(dtResult.Rows[0][0]);
Response.Redirect(String.Format("Admin/OrderDetails.aspx?Id={0}", customerId.ToString()));