I am quite desperate now because I made a nice webshop with a gridview where the customer is able to update the amount of products (Hostas in my situation) or delete the row.
The problem is that every works really fine with this code when customers order approximatelly a maximum of 35 products.
What I learned so far is to set the EnableViewState="False" for all the labels that don't need a viewstate. This helped a lot.
What can I do to make this work for an unlimited order?
You help is very appreciated!!!!!
This is my code so far:
Expand|Select|Wrap|Line Numbers
- <asp:AccessDataSource id="AccessDataSource1" Runat="Server"
- DataFile="<%$ connectionStrings: AccessHostaConnection %>"
- OnSelected="Get_Rows"
- SelectCommand="SELECT * FROM ShopCart WHERE OrderNumber=@OrderNumber order by naam"
- UpdateCommand="UPDATE ShopCart SET Aantal=@Aantal
- WHERE OrderNumber=@OrderNumber AND HostaID=@HostaID"
- DeleteCommand="DELETE FROM ShopCart
- WHERE OrderNumber=@OrderNumber AND HostaID=@HostaID"
- >
- <SelectParameters>
- <asp:ControlParameter Name="OrderNumber" ControlId="OrderNumberLabel"
- PropertyName="Text"/>
- </SelectParameters>
- <UpdateParameters>
- <asp:ControlParameter Name="OrderNumber" ControlId="OrderNumberLabel"
- PropertyName="Text"/>
- </UpdateParameters>
- <DeleteParameters>
- <asp:ControlParameter Name="OrderNumber" ControlId="OrderNumberLabel"
- PropertyName="Text"/>
- </DeleteParameters>
- </asp:AccessDataSource>
- <asp:Label ID="Label1" Text="Hosta Shopcart" Font-Size="14pt" ForeColor="#8E001C"
- Runat="Server"/> <asp:hyperlink id="Catalogus" Text="Continue shopping" navigateUrl="nwcatalog2.aspx" runat="server"> </asp:hyperlink>
- <asp:Label ID="voorraad" runat="server" ></asp:Label>
- <asp:Label ID="logtekstlabel" runat="server"></asp:Label>
- <table border="0">
- <tr>
- <td><b>Order number: </b></td>
- <td><asp:Label id="OrderNumberLabel" Runat="Server"/></td>
- </tr>
- </table>
- <table>
- <tr>
- <td>
- <b>You can change the amount of Hostas by means of the "Change"-button per
- Hosta. Subsequently you can change the amount you wish to order and finally you
- need to confirm your change by the "Update"-button.</td>
- </tr>
- </table>
- <asp:Label id="NoItemsMessage" Runat="Server"
- Text="No Hostas in Shopcart" EnableViewState="False" Visible="False"
- Width="206px" Height="1px" BackColor="#E0E0E0" ForeColor="#8E001C"
- BorderStyle="Solid" BorderWidth="1px" BorderColor="Silver"
- Style="margin-top:10px; padding:15px"/>
- <asp:Panel ID="Panel1" Width="700" Runat="Server"
- ForeColor="#990000" HorizontalAlign="Left">
- <asp:Label id="ErrMessage" Text=" " EnableViewState="False" Runat="Server"/>
- </asp:Panel>
- <asp:AccessDataSource id="ShopCartSource" Runat="Server"
- DataFile="<%$ connectionStrings: AccessHostaConnection %>"
- OnSelected="Get_Rows"
- SelectCommand="SELECT * FROM ShopCart WHERE OrderNumber=@OrderNumber order by naam"
- UpdateCommand="UPDATE ShopCart SET Aantal=@Aantal
- WHERE OrderNumber=@OrderNumber AND HostaID=@HostaID"
- DeleteCommand="DELETE FROM ShopCart
- WHERE OrderNumber=@OrderNumber AND HostaID=@HostaID"
- >
- <SelectParameters>
- <asp:ControlParameter Name="OrderNumber" ControlId="OrderNumberLabel"
- PropertyName="Text"/>
- </SelectParameters>
- <UpdateParameters>
- <asp:ControlParameter Name="OrderNumber" ControlId="OrderNumberLabel"
- PropertyName="Text"/>
- </UpdateParameters>
- <DeleteParameters>
- <asp:ControlParameter Name="OrderNumber" ControlId="OrderNumberLabel"
- PropertyName="Text"/>
- </DeleteParameters>
- </asp:AccessDataSource>
- <asp:GridView id="ShopCartGrid" DataSourceID="ShopCartSource" Runat="Server"
- AutoGenerateColumns="False"
- DataKeyNames="OrderNumber,HostaID"
- onrowupdating="Shopcart_RowUpdating"
- onrowdeleting="Shopcart_Rowdeleting"
- Cellpadding="3"
- ShowFooter="True"
- >
- <Columns>
- <asp:TemplateField
- HeaderText="Name" HeaderStyle-HorizontalAlign="Left"
- ItemStyle-Width="150">
- <ItemTemplate>
- <asp:Label ID="Label4" Runat="Server" EnableViewState="False"
- Text='<%# Bind("Naam") %>'/>
- </ItemTemplate>
- <EditItemTemplate>
- <asp:Label ID="Label5" Runat="Server" EnableViewState="False"
- Text='<%# Bind("Naam") %>'/>
- </EditItemTemplate>
- </asp:TemplateField>
- <asp:TemplateField
- HeaderText="Photo" HeaderStyle-HorizontalAlign="Left"
- ItemStyle-Width="50">
- <ItemTemplate>
- <asp:Image ImageUrl='<%# Eval("Naam", "http://www.hostaparadise.com/images/thumbs/{0}.jpg") %>' EnableViewState="False" runat="server"/>
- </ItemTemplate>
- </asp:TemplateField>
- <asp:TemplateField
- HeaderText="Price"
- ItemStyle-HorizontalAlign="Right"
- ItemStyle-Width="50">
- <ItemTemplate>
- <asp:Label ID="Label6" Runat="Server" EnableViewState="False"
- Text='<%# String.Format("€ {0:C},00", Eval("Prijs")) %>'/>
- </ItemTemplate>
- <EditItemTemplate>
- <asp:Label ID="Label7" Runat="Server" EnableViewState="False"
- Text='<%# String.Format("€ {0:C},00", Eval("Prijs")) %>'/>
- </EditItemTemplate>
- </asp:TemplateField>
- <asp:TemplateField
- HeaderText="Number"
- ItemStyle-Width="60"
- FooterStyle-HorizontalAlign="Right"
- ItemStyle-HorizontalAlign="Right">
- <ItemTemplate>
- <asp:Label ID="Label8" Runat="Server" EnableViewState="False"
- Text='<%# String.Format("{0:D}", Eval("Aantal")) %>'
- Width="25" Font-Size="9pt" Style="text-align:right"/>
- </ItemTemplate>
- <EditItemTemplate>
- <asp:TextBox id="Number" Runat="Server" EnableViewState="False"
- Text='<%# Bind("Aantal") %>'
- MaxLength="4" Width="25" Height="17" Font-Size="9pt"
- Style="padding:0px; text-align:right"/>
- </EditItemTemplate>
- <FooterTemplate>
- <asp:Label ID="Label10" Text="Total" Runat="Server" EnableViewState="False"
- Font-Bold="True" Width="50" BorderStyle="Solid" BorderWidth="0"
- Style="padding:2px; margin-top:5px"/>
- </FooterTemplate>
- </asp:TemplateField>
- <asp:TemplateField HeaderText="Amount"
- ItemStyle-Width="80"
- ItemStyle-HorizontalAlign="Right"
- FooterStyle-HorizontalAlign="Right">
- <ItemTemplate>
- <asp:Label ID="Label11" Runat="Server" EnableViewState="False"
- Text='<%# String.Format("{0:C}", _
- Get_Amount(Eval("Prijs"), Eval("Aantal"))) %>'/>
- </ItemTemplate>
- <EditItemTemplate>
- <asp:Label ID="Label12" Runat="Server" EnableViewState="False"
- Text='<%# String.Format("{0:C}", _
- Get_Amount(Eval("Prijs"), Eval("Aantal"))) %>'/>
- </EditItemTemplate>
- <FooterTemplate>
- <asp:Label id="OrderTotal" Runat="Server"
- Text='<%# String.Format("{0:C}", Get_Order_Total()) %>'
- Width="80" Font-Bold="True" BorderStyle="Solid" BorderWidth="1"
- BorderColor="#C0C0C0" Style="padding:2px; margin-top:5px"/>
- </FooterTemplate>
- </asp:TemplateField>
- <asp:TemplateField
- HeaderText="Modify order"
- ItemStyle-Width="110"
- FooterStyle-BackColor="#E0E0E0">
- <ItemTemplate>
- <asp:Button ID="Button1" Text="Change" CommandName="Edit" Runat="Server"
- Font-Size="7pt" Width="50"/>
- <asp:Button ID="Button2" Text="Delete" CommandName="Delete" Runat="Server"
- Font-Size="7pt" Width="50"/>
- </ItemTemplate>
- <EditItemTemplate>
- <asp:Button ID="Button3" Text="Update" CommandName="Update" Runat="Server"
- Font-Size="7pt" Width="50"/>
- <asp:Button ID="Button4" Text="Cancel" CommandName="Cancel" Runat="Server"
- Font-Size="7pt" Width="50"/>
- </EditItemTemplate>
- <FooterTemplate>
- <asp:Button ID="Button5" Text="Finalise order »" OnClick="Submit_Form" EnableViewState="False" Runat="Server" Font-Size="8pt" Width="75" Style="margin-top:22px"/>
- </FooterTemplate>
- </asp:TemplateField>
- </Columns>
- </asp:GridView>
- </form>
- </body>
- </html>