New test.
[mono.git] / mcs / class / System.Web / Test / standalone / checkbox / checkbox-label.aspx
1 <!--
2 In this case, we have a checkbox inside a repeater control, which is a
3 naming container. We need to make sure to use the correct attribute on
4 the label element so that the browser knows how to hook up the label
5 and the widget.
6 -->
7
8 <%@ Page Language="C#" AutoEventWireup="True" %>
9 <%@ Import Namespace="System.Data" %>
10
11 <html>
12 <head>
13 <script runat="server">
14         void Page_Load (object s, EventArgs e)
15         {
16                 if (IsPostBack)
17                         return;
18                 
19                 DataTable t = new DataTable ("t");
20                 
21                 t.Columns.Add (new DataColumn ("Symbol", typeof (string)));
22                 t.Columns.Add (new DataColumn ("Company", typeof (string)));
23                 t.Columns.Add (new DataColumn ("Price", typeof (double)));
24
25                 DataSet ds = new DataSet ("ds");
26
27                 ds.Tables.Add (t);
28                 AddStock (t, "MSFT", "Microsoft Corp.", 25.81);
29                 AddStock (t, "NOVL", "Novell Inc.", 6.17);
30                 AddStock (t, "GOOG", "Google", 300.95);
31
32                 rep.DataSource = ds;
33                 rep.DataMember = "t";
34                 rep.DataBind ();                
35         }
36
37         void AddStock (DataTable dt, string symbol, string co, double price)
38         {
39                 DataRow dr = dt.NewRow ();
40                 dr [0] = symbol;
41                 dr [1] = co;
42                 dr [2] = price;
43                 dt.Rows.Add (dr);
44         }
45 </script>
46 </head>
47 <body>
48         <asp:Label id="lbl1" runat="server" />
49         <form runat="server">
50                 <asp:Repeater id="rep" runat="server">
51                         <HeaderTemplate>
52                                 <table>
53                                         <thead>
54                                                 <tr>
55                                                 <td>Stock</td>
56                                                 <td>Company</td>
57                                                 <td>Price</td>
58                                                 <td>Buy</td>
59                                                 </tr>
60                                         </thead>
61                         </HeaderTemplate>
62                         <ItemTemplate>
63                                 <tr>
64                                         <td><%# DataBinder.Eval (Container.DataItem, "Symbol") %></td> 
65                                         <td><%# DataBinder.Eval (Container.DataItem, "Company") %></td>
66                                         <td><%# DataBinder.Eval (Container.DataItem, "Price") %></td>
67                                         <td><asp:checkbox id="buy" runat="server" text="Buy"/></td>
68                                 </tr>
69                         </ItemTemplate>
70                         <FooterTemplate>
71                                 </table>
72                         </FooterTemplate>
73                 </asp:Repeater>
74         </form>
75 </body>
76 </html>