Data Binding ASP.Net Tutorial

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Collections.Generic" %>
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

    public class CartItem
    {
        private int _id;
        public string _description;
        public int Id
        {
            get { return _id; }
        }
        public string Description
        {
            get { return _description; }
        }
        public CartItem(int id, string description)
        {
            _id = id;
            _description = description;
        }
    }
    void Page_Load()
    {
        if (!IsPostBack)
        {
            List shoppingCart = new List();
            shoppingCart.Add(new CartItem(1, "A"));
            shoppingCart.Add(new CartItem(2, "B"));
            shoppingCart.Add(new CartItem(3, "C"));
            lstShoppingCart.DataSource = shoppingCart;
            lstShoppingCart.DataBind();
        }
    }



    Programmatic DataBinding


    
    

            id="lstShoppingCart"
        DataTextField="Description"
        DataValueField="Id"
        Runat="server" />