<%@ 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;
}
}
}
|