Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old January 3rd, 2007, 04:11 PM
Authorized User
Join Date: Sep 2006
Location: , , .
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing ID query


I have an e-commerce website written in asp 1.1, vb.net and utilising an access database. Within the database I have a ProductID value to identify each product. Within the following sub procedure I want to be able to reference this value as I want to be able to check if there are enough items in stock. The code below uses the cartitemID and quantity as variables. However to reference individual items in the database I surely will need to pass the ProductID value. How should I approach this ?

   Sub dgCart_Update(sender As Object, e As DataGridCommandEventArgs)

        Dim intCartitemID As Integer
        Dim txtQuantity As TextBox
        Dim intQuantity As Integer

        'Passes ProductID as sender

        'Dim intProductID As Integer ??????

        intCartitemID = dgCart.DataKeys(e.Item.ItemIndex)
        txtQuantity = e.Item.FindControl("txtQuantity")
        intQuantity = txtQuantity.Text

        'Define intQuantityInStock and reference to CheckQuantity function
        Dim intQuantityInStock As Integer = CheckQuantity(intProductID)

        'If statement to check enough quantity in stock
        If intQuantityInStock < intQuantity
            lblError.Text = "This item is currently low in stock. Please select an alternative</b>"
            lblError.Visible = True
            Dim strSQL As String = "UPDATE [tblCartItems] SET [intQuantityOrder]=@Quantity WHERE "& _
            "intCartitemID = @intCartitemID"

            Dim dbCommand As New OleDbCommand(strSQL, dbConnection)

            Dim cmd As New OleDbCommand

            dbCommand.Parameters.Add("@Quantity", intQuantity)
            dbCommand.Parameters.Add("@intCartitemID", intCartitemID)


            dgCart.EditItemIndex = -1
            dgCart.DataSource = DisplayCart()

        End If

    End Sub

  #2 (permalink)  
Old January 4th, 2007, 03:24 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

As long as you include a grid column with the product ID in it (even a hidden column) you can get at that column's value through that column's cell in the datagrid item passed in with the event (e.Item...):

     e.Item.Cells(<cell index of product id>).Text

  #3 (permalink)  
Old January 7th, 2007, 10:45 AM
Authorized User
Join Date: Sep 2006
Location: , , .
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts


Similar Threads
Thread Thread Starter Forum Replies Last Post
Update DB by passing ID number jonsey Classic ASP Professional 1 April 11th, 2007 07:05 PM
Passing asp control id to javascript jazzcatone ASP.NET 1.0 and 1.1 Professional 0 October 18th, 2006 01:38 PM
Passing the Id to another form louie001 ASP.NET 1.0 and 1.1 Basics 1 July 14th, 2006 06:45 AM
passing session Id via email ? Gotaka4 Pro PHP 2 March 30th, 2005 09:24 AM
Passing a variable into the id() function EstherMStrom XSLT 5 January 19th, 2005 02:32 PM

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