M
Me LK
Hi,
I understand the code for passing a parameter of one field item from a
button using the command argument. What I need to do is pass three
fields. For example
My button code currently is as follows:
--------------------------------------------------------------------------------------------
Inside a data grid
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton id=linkButton CommandArgument='<
%#databinder.eval(Container.dataitem, "intProductID") %>' Text="Buy"
Runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
--------------------------------------------------------------------------------------------------
My codebehind is
Private Sub itemInfo_itemCommand(ByVal source As Object, ByVal e As
System.web.UI.WebControls.DataGridCommandEventArgs) Handles
itemInfo.ItemCommand
'The command arguement of the button that was clicked
'In the datagrid contains the productID
Dim intProductID As Integer = e.CommandArgument
'Add the product to the shopping cart
ShoppingCart.AddProduct(intProductID)
End Sub
------------------------------------------------------------------------------------------
ShoppingCart.AddProduct(intProductID) is in a class document and is as
follows
Public Shared Function AddProduct(ByVal intProductID As Integer)
' Create the connection object
Dim connection As New SqlConnection(connectionString)
' Create and initialize the command object
Dim command As New SqlCommand("AddProductToCart", connection)
command.CommandType = CommandType.StoredProcedure
' Add an input parameter and supply a value for it
command.Parameters.Add("@CartID", SqlDbType.Char, 36)
command.Parameters("@CartID").Value = shoppingCartID
' Add an input parameter and supply a value for it
command.Parameters.Add("@intProductID", SqlDbType.Int)
command.Parameters("@intProductID").Value = intProductID
' Open the connection, execute the command, and close the
connection
Try
connection.Open()
command.ExecuteNonQuery()
Finally
connection.Close()
End Try
End Function
Now I not only need to pass IntProductID but also size and color. How
will I create three parameters using a button?
Would love ideas
Thanks
LK
I understand the code for passing a parameter of one field item from a
button using the command argument. What I need to do is pass three
fields. For example
My button code currently is as follows:
--------------------------------------------------------------------------------------------
Inside a data grid
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton id=linkButton CommandArgument='<
%#databinder.eval(Container.dataitem, "intProductID") %>' Text="Buy"
Runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
--------------------------------------------------------------------------------------------------
My codebehind is
Private Sub itemInfo_itemCommand(ByVal source As Object, ByVal e As
System.web.UI.WebControls.DataGridCommandEventArgs) Handles
itemInfo.ItemCommand
'The command arguement of the button that was clicked
'In the datagrid contains the productID
Dim intProductID As Integer = e.CommandArgument
'Add the product to the shopping cart
ShoppingCart.AddProduct(intProductID)
End Sub
------------------------------------------------------------------------------------------
ShoppingCart.AddProduct(intProductID) is in a class document and is as
follows
Public Shared Function AddProduct(ByVal intProductID As Integer)
' Create the connection object
Dim connection As New SqlConnection(connectionString)
' Create and initialize the command object
Dim command As New SqlCommand("AddProductToCart", connection)
command.CommandType = CommandType.StoredProcedure
' Add an input parameter and supply a value for it
command.Parameters.Add("@CartID", SqlDbType.Char, 36)
command.Parameters("@CartID").Value = shoppingCartID
' Add an input parameter and supply a value for it
command.Parameters.Add("@intProductID", SqlDbType.Int)
command.Parameters("@intProductID").Value = intProductID
' Open the connection, execute the command, and close the
connection
Try
connection.Open()
command.ExecuteNonQuery()
Finally
connection.Close()
End Try
End Function
Now I not only need to pass IntProductID but also size and color. How
will I create three parameters using a button?
Would love ideas
Thanks
LK