2016-05-20 112 views
-3

我有一個購物頁面,但數量有問題,我不知道如何挑選文本框的值,這是我的代碼。購物車asp.net c#

<table class="table table-condensed"> 
 
\t \t \t \t \t <thead> 
 
\t \t \t \t \t \t <tr class="cart_menu"> 
 
\t \t \t \t \t \t \t <td class="image">Product</td> 
 
          <td><div class="col-md-1"></div> </td> 
 
\t \t \t \t \t \t \t <td class="description"></td> 
 
\t \t \t \t \t \t \t <td class="price">Price</td> 
 
\t \t \t \t \t \t \t <td class="quantity">Quantity</td> 
 
\t \t \t \t \t \t \t <td class="total">Total</td> 
 
\t \t \t \t \t \t \t <td><div class="col-md-1"></div></td> 
 
\t \t \t \t \t \t </tr> 
 
\t \t \t \t \t </thead> 
 
\t \t \t \t \t <tbody> 
 
         
 
         <!-- begin Cart --> 
 
         <% for(int j=0;j<NoItems;j++) 
 
          { 
 
           Label8.Text = j.ToString(); 
 
           view();%> 
 
         
 
\t \t \t \t \t \t <tr> 
 
          <td style="display:block"> 
 
            <asp:Label ID="Label8" runat="server"></asp:Label></td> 
 
\t \t \t \t \t \t \t <td class="cart_product">       
 
\t \t \t \t \t \t \t \t <a href="#"><img src="/WebVenta/img/enrollable2.jpg" alt="" width="110"></a>       
 
\t \t \t \t \t \t \t </td> 
 
          <td><div class="col-md-1"></div></td> 
 
\t \t \t \t \t \t \t <td class="cart_description"> 
 
           
 
\t \t \t \t \t \t \t \t <h4><a href="/WebVenta/Page/Producto.aspx">Persiana Enrollable</a></h4> 
 
\t \t \t \t \t \t \t \t <p><asp:Label ID="Label1" runat="server" Text=''></asp:Label></p> 
 
\t \t \t \t \t \t \t </td> 
 
\t \t \t \t \t \t \t <td class="cart_price"> 
 
\t \t \t \t \t \t \t \t <p><asp:Label ID="Label2" runat="server" Text=""></asp:Label></p> 
 
\t \t \t \t \t \t \t </td> 
 
\t \t \t \t \t \t \t <td class="cart_quantity"> 
 
\t \t \t \t \t \t \t \t <div class="cart_quantity_button"> \t \t \t \t \t \t 
 
             <asp:TextBox ID="Cantidad" class="cart_quantity_input" runat="server" Width="50px"></asp:TextBox> \t \t \t \t 
 
\t \t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t \t </td> 
 
\t \t \t \t \t \t \t <td class="cart_total"> 
 
\t \t \t \t \t \t \t \t <p class="cart_total_price"><asp:Label ID="Label3" runat="server" Text="Label" autocomplete="off" size="2"></asp:Label></p> 
 
\t \t \t \t \t \t \t </td> 
 
\t \t \t \t \t \t \t <td class="cart_delete"> 
 
\t \t \t \t \t \t \t \t <a class="cart_quantity_delete" onclick="Borrar()" runat="server"><i class="fa fa-times"></i></a>  
 
\t \t \t \t \t \t \t </td> 
 
\t \t \t \t \t \t </tr> 
 
         <% i++; 
 
          } %> 
 

 
         <!-- end --> 
 

 
\t \t \t \t \t </tbody> 
 
\t \t \t \t </table> 
 

 

 
now in the behind code have this 
 

 
public string[,] Carrito = new string[20, 13]; 
 
NoItems = Convert.ToInt32(Session["NoItems"]);//its the number of differents items 
 
Carrito = (String[,])Session["Cart"];//its a array with all products 
 

 

 
public void view() 
 
{ 
 
    Label1.Text = (String)Carrito[i, 1] + "/" + (String)Carrito[i, 3] + "/" + (String)Carrito[i, 4] + "/" + (String)Carrito[i, 5] + "/" + (String)Carrito[i, 6] + "/" + 
 
     (String)Carrito[i, 7] + "/" + (String)Carrito[i, 8] + "/" + (String)Carrito[i, 9] + "/" + (String)Carrito[i, 10]; 
 
    Label2.Text = "$" + (String)Carrito[i, 2]; 
 
    Label3.Text = "$" + (String)Carrito[i, 2]; 
 
    Cantidad.Text = (String)Carrito[i, 13]; 
 
} 
 

 
public void comprar(object sender, EventArgs e) 
 
{ 
 
    for (int a = 0; a < NoItems; a++) 
 
    { 
 
     
 
    } 
 
}

現在我的問題,它如何保存產品的數量,

現在我不使用一個數據庫,所有的信息,其在會議中,數據庫是在進展。

有什麼想法?對不起我的英語。

回答

0

您可以通過解析文本從Cantidad

int quantity = 0; 
int.TryParse(Cantidad.Text, out quantity); 

閱讀量你也應該改變Cantidad的class屬性CssClass