ASP.NET实现提取数据到table中 不用服务器控件

1.后台方法
public string id;
public string usercode;
public void tbalelist(string strsql)
{
string str = string.Empty;
DBCon OAcon = new DBCon();
SqlConnection myConn = new SqlConnection(OAcon.getOAcon());
myConn.Open();
SqlCommand sc = new SqlCommand(strsql, myConn);
SqlDataReader sr = sc.ExecuteReader();
if(sr.Read())
{
id=sr[0].ToString();
usercode = sr[1].ToString();
}
sr.Close();
myConn.Close();

}
2.前台
<table align="center" border="0" cellpadding="5" cellspacing="1" width="100%">
<tr>
<td class="hback" width="5%">
<font color="#cc3300"><b>ID</b></font></td>
<td class="hback" width="10%">
<font color="#cc3300"><b>张号</b></font></td>

</tr>
<tr>
<td class="hback" width="5%"><%= id %></td>
<td class="hback" width="10%"><%= usercode %></td>
</tr>
</table>

你可能感兴趣的:(asp.net)