I plan to port the project to mono, and I will do the test.
Write An aspx webpage first. Add the datalist control. The Code is as follows:
<% @ Page language = "c #" Inherits = "TestASPNET. WebForm2" %>
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML>
<HEAD>
<Title> WebForm2 </title>
<Meta name = "GENERATOR" Content = "Microsoft Visual Studio. NET 7.1">
<Meta name = "CODE_LANGUAGE" Content = "C #">
<Meta name = "vs_defaultClientScript" content = "JavaScript">
<Meta name = "vs_targetSchema"
Content = "http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<Body>
<Form id = "Form1" method = "post" runat = "server">
<Asp: DataList id = "dglist" runat = "server">
<ItemTemplate>
<Asp: Label id = "Label7"
Runat = "server"> identifier </asp: Label>
<Asp: Label id = Label1
Runat = "server" Text = '<% # DataBinder. Eval
(Container. DataItem, "title") %> '>
</Asp: Label> <FONT
Face = ""> <BR>
</FONT>
<Asp: Label id = "Label8"
Runat = "server"> content </asp: Label>
<Asp: Label id = "Label4"
Runat = "server"> creation time </asp: Label>
<Asp: Label id = "Label5"
Runat = "server" Text = '<% # DataBinder. Eval
(Container. DataItem, "createdate") %> '>
</Asp: Label> <BR>
<Asp: Label id = Label2
Runat = "server" Text = '<% # DataBinder. Eval (Container. DataItem, "Text ")
%> '>
</Asp: Label> <BR>
<BR>
</ItemTemplate>
</Asp: DataList>
</Form>
</Body>
</HTML>
The most important thing is to add the following sentence:
<% @ Page language = "c #" Inherits = "TestASPNET. WebForm2" %>
Next, write the codebind code: WebForm2.cs
Using System;
Using System. Data;
Using System. Web;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Namespace TestASPNET
{
Public class WebForm2: System. Web. UI. Page
{
Protected System. Web. UI. WebControls. DataList dglist;
Private void Page_Load (object sender, System. EventArgs e)
{
If (this. IsPostBack = false)
{
This. BindingData ();
}
}
Private void BindingData ()
{
System. Data. DataSet myds = new DataSet ();
String path = Server. MapPath ("./file. xml ");
Myds. ReadXml (path );
Dglist. DataSource = myds. Tables ["file"];
This. DataBind ();
}
Override protected void OnInit (EventArgs e)
{
InitializeComponent ();
Base. OnInit (e );
}
Private void InitializeComponent ()
{
This. Load + = new System. EventHandler (this. Page_Load );
}
}
}
Next, compile WebForm2.cs and create the Bin directory.
The command is as follows:
mcs /t:library /out:TestASPNET.dll -r:System.Web -r:System.Data WebForm2.aspx.cs
Next, copy TestASPNET. dll to the web directory Bin.
Start xsp
Http: /localhost: 8088/WebForm2.aspx
The result is displayed.