2016-05-04 9 views
0

Ich möchte eine andere Seite sehenDatenansicht ID in asp.net mit

Response.redirect 

verwenden, aber ein customerID zusammen mit ihm unter Berücksichtigung. hier meine Button-Code ist:

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}"); 

Was sie tut, ist, dass sie dann am Ende alle die Benutzereingabe wird, möchte ich seine/ihre Bestellung Zusammenfassung für den Benutzer zeigen. Wie Sie sehen können, versuche ich Response.Redirect zu verwenden.

Das Problem ist, ich die aktuelle customerID verwenden möchten, wenn ich die Verwendung

Response.Redirect("Admin/OrderDetails.aspx?Id={0}"); 

irgendwelche Tricks dazu?

+0

Verwenden Session Variable – techspider

+0

Sie mir eine Probe sir geben kann? bitte und danke –

+0

Warum können Sie Query String nicht hinzufügen? Was ist das Problem? – techspider

Antwort

0

Sie haben CustomerID bereits. Ersetzen {0} vor mit diesem Wert Umleiten

var customerId = Convert.ToInt32(dtResult.Rows[0][0]); 
Response.Redirect(String.Format("Admin/OrderDetails.aspx?Id={0}", customerId.ToString()));