Page with declarative data binding : BulletedList « Data Binding « ASP.NET Tutorial






<%@ Page Language="C#" Debug="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Simple page with declarative data binding</title>
</head>
<body>
    <form runat="server" id="_form">
        
        
        <asp:BulletedList runat="server" ID="_displayItems" 
                          DataSourceID="_itemsDataSource">
            <asp:ListItem>Sample item 1</asp:ListItem>
            <asp:ListItem>Sample item 2 ...</asp:ListItem>
        </asp:BulletedList>
        
        <h2 runat="server" id="_messageH2">Total number of items = xx</h2>
        
        <asp:ObjectDataSource runat="server" ID="_itemsDataSource"
             TypeName="Architecture.MyDataSource"
             SelectMethod="GetItems" />
    </form>
</body>
</html>


File: MyDataSource.cs

using System;

namespace Architecture
{
  public static class MyDataSource
  {
    static string[] _items = 
      {"Item #1", "Item #2", "Item #3", "Item #4", 
       "Item #5", "Item #6", "Item #7", "Item #8", 
       "Item #9", "Item #10"};

    public static string[] GetItems()
    {
      return _items;
    }
  }
}








19.2.BulletedList
19.2.1.BulletedList Control data binding with asp:SqlDataSource
19.2.2.BulletStyle property
19.2.3.DisplayMode property: BulletedList DisplayMode enumeration
19.2.4.Simple Page With Data Binding
19.2.5.Page with declarative data binding