V
VB Programmer
Using ASP.NET 2.0...
My GridView is partially defined as such....
<asp:GridView ID="CartGrid" AutoGenerateColumns="False"
DataKeyNames="ID" OnSelectedIndexChanged="RemoveCartItem"
CellPadding="4" runat="Server"
ForeColor="Gray" GridLines="None" Width="90%"
BorderStyle="Inset"
BorderWidth="1px" Caption="Shopping Cart" Font-Bold="False"
CaptionAlign="Left">
<Columns>
<asp:ButtonField
CommandName="select" Text="Remove" />
<asp:BoundField
DataField="Name" HeaderText="Name">
<ControlStyle
Width="300px" />
<ItemStyle Width="300px"
/>
As you can see, when the user clicks "Remove" it runs the "RemoveCartItem"
function, defined as such...
Sub RemoveCartItem(ByVal s As Object, ByVal e As EventArgs) Handles
CartGrid.SelectedIndexChanged
Dim ID As String = CartGrid.SelectedDataKey.Value
Profile.MyShoppingCart.RemoveItem(ID)
BindShoppingCart()
End Sub
Sub BindShoppingCart()
If Not Profile.MyShoppingCart Is Nothing Then
CartGrid.DataSource = Profile.MyShoppingCart.CartItems
CartGrid.DataBind()
lblTotal.Text = Profile.MyShoppingCart.Total.ToString("c")
BindShippingDdl()
End If
End Sub
I put a breakpoint on RemoveCartItem and the code is running twice each
time. Any ideas why?
Thanks!
My GridView is partially defined as such....
<asp:GridView ID="CartGrid" AutoGenerateColumns="False"
DataKeyNames="ID" OnSelectedIndexChanged="RemoveCartItem"
CellPadding="4" runat="Server"
ForeColor="Gray" GridLines="None" Width="90%"
BorderStyle="Inset"
BorderWidth="1px" Caption="Shopping Cart" Font-Bold="False"
CaptionAlign="Left">
<Columns>
<asp:ButtonField
CommandName="select" Text="Remove" />
<asp:BoundField
DataField="Name" HeaderText="Name">
<ControlStyle
Width="300px" />
<ItemStyle Width="300px"
/>
As you can see, when the user clicks "Remove" it runs the "RemoveCartItem"
function, defined as such...
Sub RemoveCartItem(ByVal s As Object, ByVal e As EventArgs) Handles
CartGrid.SelectedIndexChanged
Dim ID As String = CartGrid.SelectedDataKey.Value
Profile.MyShoppingCart.RemoveItem(ID)
BindShoppingCart()
End Sub
Sub BindShoppingCart()
If Not Profile.MyShoppingCart Is Nothing Then
CartGrid.DataSource = Profile.MyShoppingCart.CartItems
CartGrid.DataBind()
lblTotal.Text = Profile.MyShoppingCart.Total.ToString("c")
BindShippingDdl()
End If
End Sub
I put a breakpoint on RemoveCartItem and the code is running twice each
time. Any ideas why?
Thanks!