Skip to content
Loading
product description inserted in database table    
  •            
  •            
  •     
  •            
  •     
  •        
  •        
  •    "button1" runat="server" text="add to cart" />    
  • Then aspx.cs as
    1. protected void Button1_Click(object sender, EventArgs e)  
    2. {  
    3.     string Name,Price,Quantity,description;  
    4.     foreach (RepeaterItem item in Repeater1.Items)  
    5.     {  
    6.         Name = (Label)item.FindControl("product_name");  
    7.         price=(Label)item.FindControl("product_price");  
    8.         Quantity = (Label)item.FindControl("product_qty");  
    9.         desc=(Label)item.FindControl("product_description");  
    10.     }  
    11.   
    12.     using(SqlConnection con=new SqlConnection(conn))  
    13.     {  
    14.         SqlCommand cmd=new SqlCommand("Insert into Product values(@Name,@desc,@Price,@Quantity,)",con);
    15.         cmd.parameters.AddwithValue("@Name",Name);  
    16.         cmd.parameters.AddwithValue("@price",price);  
    17.         cmd.parameters.AddwithValue("@Quantity",Quantity);  
    18.         cmd.parameters.AddwithValue("@price",price);  
    19.         con.Open();  
    20.         cmd.ExecuteNonQuery();  
    21.     }  
    22. }
  • In previous example image also has to be inserted into database table...how can doit?
  • Mageshwaran R
    Hi Upen,
    please refer this link,
     
    https://www.c-sharpcorner.com/UploadFile/4aae29/complete-crud-operations-in-Asp-Net/