wishlistcontrol.ascx.vb
来自「C#语言制作asp.net网上商店的」· VB 代码 · 共 77 行
VB
77 行
Imports NetShopForge.Library.WishList
Imports NetShopForge.Library.Product
Partial Class Shop_User_Controls_WishListControl
Inherits System.Web.UI.UserControl
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim pID As String = Request("pID")
If Not IsNothing(pID) Then
WishController.AddProductReview(CInt(pID), My.User.Name)
End If
BindData()
End If
End Sub
Private Sub BindData()
gvWish.DataSource = WishController.GetWishList(My.User.Name)
gvWish.DataBind()
End Sub
Protected Sub gvWish_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvWish.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim btnAddToCart As Button = CType(e.Row.FindControl("btnAddToCart"), Button)
Dim pID As Integer = CInt(gvWish.DataKeys(e.Row.RowIndex).Item("ProductID"))
If ProductController.HasProductOption(pID) Then
btnAddToCart.CommandArgument = String.Format("{0}|1", pID.ToString)
btnAddToCart.Text = "查看详细"
Else
btnAddToCart.CommandArgument = String.Format("{0}|0", pID.ToString)
btnAddToCart.Text = "加入购入车"
End If
End If
End Sub
Protected Sub btnAddToCart_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim keys As String() = CType(sender, Button).CommandArgument.Split("|")
Dim pID As Integer = CInt(keys(0))
Dim b As Boolean = CBool(keys(1))
If b Then
My.Response.Redirect(String.Format("~/ProductDetail.aspx?pID={0}", pID.ToString))
Else
Profile.ShoppingCart.Add(pID)
Dim msg As String = "成功加入购物车! 查看<a href=""Cart.aspx"">购物车</a>"
ResultMessageControl1.ShowSuccess(msg)
End If
End Sub
Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim wishID As Integer = CInt(CType(sender, Button).CommandArgument)
WishController.DeleteProductReview(wishID)
BindData()
End Sub
Protected Sub btnDeleteAll_Click(ByVal sender As Object, ByVal e As System.EventArgs)
For I As Integer = 0 To gvWish.Rows.Count - 1
Dim wishID As Integer = CInt(gvWish.DataKeys(I).Item("WishID"))
WishController.DeleteProductReview(wishID)
Next
BindData()
End Sub
End Class
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?