EvalTest.aspx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <%@ Page Language="C#" AutoEventWireup="true" %>
  2. <%@ Import Namespace="System.Data" %>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml" >
  5. <head runat="server">
  6. <title>Untitled Page</title>
  7. <script runat="server">
  8. public class DataObject
  9. {
  10. public static DataTable ds = CreateDataTable ();
  11. public static DataTable Select ()
  12. {
  13. return ds;
  14. }
  15. public static DataTable CreateDataTable ()
  16. {
  17. DataTable aTable = new DataTable ("A");
  18. DataColumn dtCol;
  19. DataRow dtRow;
  20. // Create ID column and add to the DataTable.
  21. dtCol = new DataColumn ();
  22. dtCol.DataType = Type.GetType ("System.String");
  23. dtCol.ColumnName = "ID";
  24. dtCol.Caption = "ID";
  25. dtCol.ReadOnly = true;
  26. dtCol.Unique = true;
  27. aTable.Columns.Add (dtCol);
  28. dtRow = aTable.NewRow ();
  29. dtRow["ID"] = "My databind test";
  30. aTable.Rows.Add (dtRow);
  31. aTable.PrimaryKey = new DataColumn[] { aTable.Columns["ID"] };
  32. return aTable;
  33. }
  34. }
  35. protected override void OnLoad (EventArgs e)
  36. {
  37. base.OnLoad (e);
  38. Repeater1.DataSource = DataObject.Select ();
  39. Repeater1.DataMember = "A";
  40. Repeater1.DataBind ();
  41. }
  42. </script>
  43. </head>
  44. <body>
  45. <form id="form1" runat="server">
  46. <div>
  47. <asp:Repeater ID="Repeater1"
  48. runat="server">
  49. <ItemTemplate>
  50. <table>
  51. <tr>
  52. <td><font color="blue"><%# Eval ("ID")%></font></td>
  53. </tr>
  54. </table>
  55. </ItemTemplate>
  56. </asp:Repeater>
  57. </div>
  58. </form>
  59. </body>
  60. </html>