Hi all, I am currently building a shopping cart using C#. I need help creating a remove item code to remove items from the shopping cart. Below are my source code for gridview I created. Please help. Thanks. :)
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID
="AccessDataSource2"
Width="100%" CellPadding="4" ForeColor="#333333" GridLines="None" OnSelectedIndexChanged
="GridView1_SelectedIndexChanged">
<Columns
>
<asp:BoundField DataField="iProductId" HeaderText="iProductId" SortExpression="iProductId"
/>
<asp:BoundField DataField="pName" HeaderText="pName" SortExpression="pName"
/>
<asp:BoundField DataField="iQty" HeaderText="iQty" SortExpression="iQty"
/>
<asp:BoundField DataField="iUnitPrice" HeaderText="iUnitPrice" SortExpression="iUnitPrice"
/>
<asp:BoundField DataField="iAmt" HeaderText="iAmt" ReadOnly="True" SortExpression="iAmt"
/>
<asp:ButtonField ButtonType="Button" Text="Remove Item"
/>
</Columns
>
GridView can auto generate delete button for you.
Since you have a datasource, the delete code is automatic too. But I think this only works if your data is from one table.