Public Class _default Inherits System.Web.UI.Page Protected WithEvents cmdInsertSession As System.Data.SqlClient.SqlCommand Protected WithEvents lblMessages As System.Web.UI.WebControls.Label Protected WithEvents grdProducts As FeaturedProducts Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here ... End Sub Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PreRender Me.grdProducts.ProductType = Me.grdProducts.GridType.Features Me.grdProducts.GetProducts() End Sub End ClassUser Control Code
Public MustInherit Class FeaturedProducts Inherits System.Web.UI.UserControl Protected WithEvents dsFeatures As WebCartMaintenance.dsWebShopper Protected WithEvents daFeatured As System.Data.SqlClient.SqlDataAdapter Protected WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand Protected WithEvents dgFeatures As System.Web.UI.WebControls.DataGrid Protected WithEvents cmdAddToCart As System.Web.UI.WebControls.Button Protected WithEvents btnAddToCartBottom As System.Web.UI.WebControls.Button Protected WithEvents SqlCommand1 As System.Data.SqlClient.SqlCommand Protected WithEvents SqlCommand2 As System.Data.SqlClient.SqlCommand Protected WithEvents daCart As System.Data.SqlClient.SqlDataAdapter Public Enum GridType Features = 1 BrandName = 2 Cart = 3 Order = 4 End Enum Private _producttype As String Public Property ProductType() Get Return _producttype End Get Set(ByVal Value) _producttype = Value End Set End Property .... Public Sub GetProducts() ... End Sub Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here Me.GetProducts() End Sub End Class