I have a gridview with a delete command...
I really need to delete items by 'Product ID', instead of 'SessionID' - that is displayed in the code below...
I have tried: " DeleteCommand=" DELETE * FROM [Basket] WHERE [SessionID] = ?" "... but it does not delete any of the records, just refreshes the gridview... Any help would be greatly appreciated.
I really need to delete items by 'Product ID', instead of 'SessionID' - that is displayed in the code below...
I have tried: " DeleteCommand=" DELETE * FROM [Basket] WHERE [SessionID] = ?" "... but it does not delete any of the records, just refreshes the gridview... Any help would be greatly appreciated.
Code:
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px"
CellPadding="4" CellSpacing="2" DataKeyNames="SessionID"
DataSourceID="AccessDataSource1" RowDataBound="GridView2_DataBound"
EmptyDataText="There are currently no items in your basket." Font-Bold="True"
Font-Names="Cambria" Font-Size="Medium" ForeColor="Black"
style="font-family: Cambria; font-size: medium">
<Columns>
<asp:CommandField ButtonType="Image" DeleteImageUrl="~/Images/x.jpg"
DeleteText="Remove" ShowDeleteButton="True" />
<asp:BoundField DataField="SessionID" HeaderText="SessionID" ReadOnly="True"
SortExpression="SessionID" Visible="False" />
<asp:BoundField DataField="ProductID" HeaderText="Offer #"
SortExpression="ProductID" />
<asp:BoundField DataField="ProductName" HeaderText="Name"
SortExpression="ProductName" />
<asp:BoundField DataField="ProductPrice" HeaderText="Price"
SortExpression="ProductPrice" DataFormatString="{0:C}" />
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="Gray" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/Db1.accdb"
SelectCommand="SELECT * FROM [Basket] WHERE ([SessionID] = ?)"
InsertCommand="INSERT INTO [Basket] ([SessionID], [ProductID], [ProductName], [ProductPrice]) VALUES (?, ?, ?, ?)"
DeleteCommand="DELETE * FROM [Basket] WHERE [SessionID] = ?">
<InsertParameters>
<asp:Parameter Name="SessionID" Type="String" />
<asp:Parameter Name="ProductID" Type="Int32" />
<asp:Parameter Name="ProductName" Type="String" />
<asp:Parameter Name="ProductPrice" Type="Decimal" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="LabelSesh" Name="SessionID"
PropertyName="Text" Type="String" />
</SelectParameters>