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实现提取数据到table中 不用服务器控件
最新推荐文章于 2021-06-19 02:12:47 发布
本文介绍了一种使用C#进行后台SQL数据读取的方法,并在网页前端展示所获取的数据。后台通过执行SQL语句从数据库中读取ID和用户代码,然后在HTML表格中显示这些信息。
2384

被折叠的 条评论
为什么被折叠?



