【www.gdgbn.com--win10】

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsdatalistclassedititemtemplatetopic.asp
<%@ Page Language="C#" AutoEventWireup="True" %>
<%@ Import Namespace="System.Data" %>


<script runat="server">
// The Cart and CartView objects temporarily store the data source
// for the DataList control while the page is being processed.
DataTable Cart = new DataTable();
DataView CartView;

void Page_Load(Object sender, EventArgs e)
{

// With a database, use an select query to retrieve the data.
// Because the data source in this example is an in-memory
// DataTable, retrieve the data from session state if it exists;
// otherwise, create the data source.
GetSource();
// The DataList control maintains state between posts to the server;
// it only needs to be bound to a data source the first time the
// page is loaded or when the data source is updated.
if (!IsPostBack)
{
string[] slist = new string[]{"a","b","c"};
DataGrid1.DataSource = slist;
DataGrid1.DataBind();

}
}
void BindList(DataList ItemsList)
{
// Set the data source and bind to the DataList control.
ItemsList.DataSource = CartView;
ItemsList.DataBind();
}
void GetSource()
{
// For this example, the data source is a DataTable that
// is stored in session state. If the data source does not exist,
// create it; otherwise, load the data.
if (Session["ShoppingCart"] == null)
{

本文来源:http://www.gdgbn.com/caozuoxitong/8563/