如何在C#ASP.NET webform中将数据库连接到bootstrap HTML表 [英] How to connect database to bootstrap HTML table in C# ASP.NET webform
本文介绍了如何在C#ASP.NET webform中将数据库连接到bootstrap HTML表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我正在研究asp.net webform上的一个项目。我使用的模板有一个已经制作的表,所以我想将表收集到数据库,以便它可以取出所有信息并将其发送到表。我打破已经制作的表格以显示数据库中的所有内容而无需从头开始创建
我尝试过:
Good day everyone i am working on a project on asp.net webform. i am using a template that has an already made table so i want to collect the table to the database so it can fetch out all the information and send it to the table. i wamnt the already made table to show everything on the database without creating from scratch
What I have tried:
StringBuilder table = new StringBuilder();
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\odt\Documents\login.mdf;Integrated Security=True;Connect Timeout=30");
;
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select * from [log] ";
cmd.Connection = con;
SqlDataReader dt = cmd.ExecuteReader();
if (dt.HasRows)
{
if (dt.Read())
{
}
}
// cmd.ExecuteNonQuery();
con.Close();
}
这是html表
this is the html table
<div class="box-body table-responsive no-padding">
<table ID="tdb" class="table table-hover" >
<tr>
<th>ID</th>
<th>User</th>
<th>Password</th>
推荐答案
你最好的选择,在ASP.NET(已经过时)是使用转发器从数据源构建引导表
Your best bet, in ASP.NET (which is obsolete) is to use a repeater to build your bootstrap table out of a data source
这篇关于如何在C#ASP.NET webform中将数据库连接到bootstrap HTML表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文