Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #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

Hi,

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 ?

Code:
   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
        Else
            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)

            dbConnection.Open()
            dbCommand.ExecuteNonQuery()
            dbConnection.Close()

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

        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
Default

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


-Peter
  #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
Default

Thanks

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:08 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.