Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 5th, 2007, 02:41 PM
Authorized User
 
Join Date: Sep 2006
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default Datagrid Query

Hi,

I have a datagrid set up which displays a list of bought items in a shopping cart. When the customer checks out I want to be able to update the original products table by reducing the quantity bought from the quantity in stock. How do I reference each item in the datagrid and relate that back to the database ? This ensures the correct item's quantity in the Products table is reduded by the number purchased.


I'm using asp.net 1.1 with vbnet 2003 and connecting to an access database. Here is the datagrid code sample :

Code:
<asp:DataGrid id="dgCart" runat="server" OnItemDataBound="ComputeSum" ShowFooter="True" DataKeyField="intCartitemID" AutoGenerateColumns="False" OnDeleteCommand="dgCart_Delete" OnCancelCommand="dgCart_Cancel" OnEditCommand="dgCart_Edit" OnUpdateCommand="dgCart_Update">
                                    <FooterStyle horizontalalign="Center" forecolor="Blue"></FooterStyle>
                                    <Columns>
                                        <asp:BoundColumn DataField="intProductID" ReadOnly="True" HeaderText="ProductID">
                                            <HeaderStyle horizontalalign="Center"></HeaderStyle>
                                            <ItemStyle horizontalalign="Center"></ItemStyle>
                                        </asp:BoundColumn>
                                        <asp:BoundColumn DataField="strMake" ReadOnly="True" HeaderText="Manufacturer">
                                            <HeaderStyle horizontalalign="Center"></HeaderStyle>
                                            <ItemStyle horizontalalign="Center"></ItemStyle>
                                        </asp:BoundColumn>
                                        <asp:BoundColumn DataField="strProductName" ReadOnly="True" HeaderText="Product Name">
                                            <HeaderStyle wrap="False" horizontalalign="Center"></HeaderStyle>
                                            <ItemStyle horizontalalign="Center"></ItemStyle>
                                        </asp:BoundColumn>
                                        <asp:BoundColumn DataField="strTypeDetails" ReadOnly="True" HeaderText="Product Type">
                                            <HeaderStyle wrap="False" horizontalalign="Center"></HeaderStyle>
                                            <ItemStyle horizontalalign="Center"></ItemStyle>
                                        </asp:BoundColumn>
                                        <asp:BoundColumn DataField="strColour" ReadOnly="True" HeaderText="Colour">
                                            <HeaderStyle horizontalalign="Center"></HeaderStyle>
                                            <ItemStyle horizontalalign="Center"></ItemStyle>
                                        </asp:BoundColumn>
                                        <asp:TemplateColumn HeaderText="Quantity">
                                            <HeaderStyle horizontalalign="Center"></HeaderStyle>
                                            <ItemStyle horizontalalign="Center"></ItemStyle>
                                            <ItemTemplate>
                                                <%# DataBinder.Eval(Container, "DataItem.intQuantityOrder") %> 
                                            </ItemTemplate>
                                            <EditItemTemplate>
                                                <asp:TextBox id="txtQuantity" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.intQuantityOrder") %>'></asp:TextBox>
                                            </EditItemTemplate>
                                        </asp:TemplateColumn>
                                        <asp:BoundColumn DataField="curSalePrice" ReadOnly="True" HeaderText="ItemPrice" DataFormatString="£{0:F2}">
                                            <HeaderStyle horizontalalign="Center"></HeaderStyle>
                                            <ItemStyle horizontalalign="Center"></ItemStyle>
                                        </asp:BoundColumn>
                                        <asp:TemplateColumn HeaderText="Amount">
                                            <HeaderStyle wrap="False" horizontalalign="Center"></HeaderStyle>
                                            <ItemStyle wrap="False" horizontalalign="Center"></ItemStyle>
                                            <ItemTemplate>
                                                Â£<%# FormatNumber(GetAmount(Container.DataItem("curSalePrice"), Container.DataItem("intQuantityOrder"))) %> 
                                            </ItemTemplate>
                                            <FooterStyle wrap="False"></FooterStyle>
                                        </asp:TemplateColumn>
                                        <asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit Quantity">
                                            <HeaderStyle wrap="False" horizontalalign="Center"></HeaderStyle>
                                            <ItemStyle horizontalalign="Center"></ItemStyle>
                                            <FooterStyle wrap="False"></FooterStyle>
                                        </asp:EditCommandColumn>
                                        <asp:ButtonColumn Text="Delete" CommandName="Delete">
                                            <HeaderStyle wrap="False" horizontalalign="Center"></HeaderStyle>
                                            <ItemStyle horizontalalign="Center"></ItemStyle>
                                            <FooterStyle wrap="False"></FooterStyle>
                                        </asp:ButtonColumn>
                                    </Columns>
                                </asp:DataGrid>
Thanks,






Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom paging in Datagrid with datagrid page count madhusrp ASP.NET 1.0 and 1.1 Professional 12 June 2nd, 2008 01:15 PM
User COntrol Datagrid inside datagrid rodmcleay ASP.NET 1.0 and 1.1 Professional 3 April 14th, 2007 10:11 AM
query to get same field twice in datagrid Aneri ASP.NET 1.0 and 1.1 Basics 1 March 1st, 2007 05:56 PM
Database / Datagrid Query rsm42 ASP.NET 1.0 and 1.1 Basics 3 January 29th, 2007 06:00 PM
Binding Results of an Xpath query to a datagrid cowa ADO.NET 2 November 17th, 2003 02:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.