<%@ Import Namespace="System.Data" %>
<html>
<script language="C#" runat="server">
DataTable Cart;
DataView CartView;
ICollection CreateDataSource() {
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
dt.Columns.Add(new DataColumn("StringValue", typeof(string)));
dt.Columns.Add(new DataColumn("DateTimeValue", typeof(DateTime)));
dt.Columns.Add(new DataColumn("BoolValue", typeof(bool)));
dt.Columns.Add(new DataColumn("CurrencyValue", typeof(double)));
for (int i = 0; i < 9; i++) {
dr = dt.NewRow();
dr[0] = i;
dr[1] = "Item " + i.ToString();
dr[2] = DateTime.Now;
dr[3] = (i % 2 != 0) ? true : false;
dr[4] = 1.23 * (i+1);
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt);
return dv;
}
void Page_Load(Object sender, EventArgs e)
{
if (Session["DG5_ShoppingCart"] == null) {
Cart = new DataTable();
Cart.Columns.Add(new DataColumn("Item", typeof(string)));
Cart.Columns.Add(new DataColumn("Price", typeof(string)));
Session["DG5_ShoppingCart"] = Cart;
}
else {
Cart = (DataTable)Session["DG5_ShoppingCart"];
}
CartView = new DataView(Cart);
ShoppingCart.DataSource = CartView;
CartView.Sort="Item";
ShoppingCart.DataBind();
MyDataGrid.DataSource = CreateDataSource();
MyDataGrid.DataBind();
}
void Grid_CartCommand(object sender, DataGridCommandEventArgs e) {
DataRow dr = Cart.NewRow();
&nbs