I am currently learning to write ASP.NET website using Visual Studio Express 2013 for Web, and I plan to develop an online shopping website. I have started a New Web Site, added a SQL Server Database (eCommerce.mdf) into the WebSite (in VS), created two tables and inserted a row of data using the following query:
CREATE TABLE product (product_id char(4) PRIMARY KEY, product_name varchar(50), product_price money, product_stock int);
INSERT INTO product VALUES ('P001', 'Omega Seamaster Planet Ocean 600m', 68000, 7);
CREATE TABLE cart (customer_id char(4), product_id char(4), cart_quantity int);
Then I have added a new web form Product.aspx into the website and a GridView to get data from the product table (it shows SelectCommand="SELECT * FROM [product]" in the source) from my database. It works fine but I want to make a Button, namely Add to cart, that can do the INSERT INTO function to add new rows to the cart table. I try to use the following codes:
Add an OnClick event in the Button html code
<asp:Button ID="Button1" runat="server" Text="Add to cart" OnClick="func1" />
I am not sure about the parameter to be passed to because I have tried a lot of examples from the Internet but none of them works for me.
From under the file, other than the with name of , it writes .
Moreover, I get the message when I click the in debugging mode if I use event instead of event.
So my question is, what should I type as the parameter and anything else should I modify to get work as expected? I also appreciate any other methods.