I’m getting “Me’ is valid only within an instance method” error when I convert function to a PageMethods.
Private Shared objDT As System.Data.DataTable
Private Shared objDR As System.Data.DataRow
<WebMethod()> Public Shared Function addstn(itemID As String) As String
For Each Me.objDR In objDT.Rows
If objDR("ProductID") = ProductID Then
If objDR("Options") = desc Then
objDR("Quantity") += 1
blnMatch = True
Exit For
End If
End If
Next
End Function
If I remove Me, I get different error.
I got this shopping cart script somewhere online and I’m not sure what to replace “Me.objDR” with something else.
Thank you in advance
The Me keyword provides a way to refer to the specific instance of a class or structure in which the code is currently executing.
In a shared context there is no instance. You can reference your variable directly or via
ClassName.VariableName.This could work(i’m not sure wherefrom the other variables are):
http://msdn.microsoft.com/en-us/library/20fy88e0%28v=vs.80%29.aspx