Session传值的问题
把一个Cart(维护一个DataSet)对象从第一个页面传到第二个页面,然后用DataList绑定
第一个页面
private cart as new Cart
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cart = New Cart
HttpContext.Current.Session( "CART ") = cart
End Sub
第二个页面
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cart As New Cart
cart = CType(HttpContext.Current.Session( "CART "), BLL.Cart)
DataList1.DataSource = cart.GetCart()
DataList1.DataBind()
End Sub
cart对象的定义
Public Class Cart
Private ds As DataSet
Private table As DataTable
Public Sub New()
ds = New DataSet
table = ds.Tables.Add( "cartInfo ")
Dim column As DataColumn
column = New DataColumn
column.ColumnName = "itemId "
column.DataType = System.Type.GetType( "System.String ")
table.Columns.Add(column)
column = New DataColumn
column.ColumnName = "itemName "
column.DataType = System.Type.GetType( "System.String ")
table.Columns.Add(column)
column = New DataColumn
column.ColumnName = "quantity "
column.DataType = System.Type.GetType( "System.String ")
table.Columns.Add(column)
column = New DataColumn
column.ColumnName = "unitPrice "
column.