Step 1: Add introduction on the front-end interface
[Html]
<% @ Import Namespace = "System. Data" %>
Step 2: Define the able in the background and assign values
[Csharp]
Protected DataTable dt = new DataTable ();
Protected void Page_Load (object sender, EventArgs e)
{
If (! IsPostBack)
{
String sConn = "data source =.; database = Test; uid = sa; pwd = 123456 ";
String SQL = "select top 10 * from TrainVideo ";
DataSet ds = SqlHelper. ExecuteDataset (sConn, CommandType. Text, SQL );
If (ds. Tables. Count> = 1)
{
Dt = ds. Tables [0];
}
}
}
Step 3: Put the display in the table on the front-end page, first judge
[Html]
<Div>
<Table>
<Tr>
<Td>
ID.
</Td>
<Td>
File Name
</Td>
</Tr>
<% If (dt! = Null & dt. Rows. Count> 11)
{
Foreach (DataRow dt_dr in dt. Rows)
{
%>
<Tr>
<Td>
<% = Dt_dr ["id"] %>
</Td>
<Td>
<% = Dt_dr ["filename"] %>
</Td>
</Tr>
<%
}
}
Else
{
%>
<Tr>
<Td colspan = "2">
No information
</Td>
</Tr>
<%}
%>
</Table>
</Div> www.2cto.com
Author: liyangfd