Hi,
Within an asp.net page I keep receiving the following error :
Public member 'DataGridCommandArgument' on type 'DataGrid' not found.
Description: An unhandled exception occurred during the execution of the current
web request. Please review the stack trace for more information about the error
and where it originated in the code.
Exception Details: System.MissingMemberException: Public member
'DataGridCommandArgument' on type 'DataGrid' not found.
Source Error:
Line 110: 'Passes ProductID as sender
Line 111:
Line 112: Dim intProductID As Integer =
sender.DataGridCommandArgument'<%# DataBinder.Eval(Container.DataItem,
"intProductID")%>'
Line 113:
Line 114:
This page is part of an e-commerce website in asp.net 1.1, vb2003 and connecting
to an access database. Basically within this checkout page I'm trying to check
there is sufficient quantity of items in stock before a customer checks out. The
way I have designed the site is that the ProductID (intProductID) is passed as a
sender to identify the relevant item within the database. Please advise how to
resolve this error. Here's some of the relevant code :
Code:
Sub dgCart_Update(sender As Object, e As DataGridCommandEventArgs)
Dim strConnString As String =
ConfigurationSettings.AppSettings.Get("ConnectionString")
strConnString = String.Format(strConnString,
Server.MapPath("\db\nwguitars.mdb"))
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(strConnString)
Dim intCartitemID As Integer
Dim txtQuantity As TextBox
Dim intQuantity As Integer
'Passes ProductID as sender
Dim intProductID As Integer = sender.DataGridCommandArgument'<%#
DataBinder.Eval(Container.DataItem, "intProductID")%>'
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)
lblQuantity.Text = intQuantity
lblQuantity.Visible = False
'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
Thanks,