在我的 MVC 应用程序中,我正在从数据库中检索数据。我想在表格中显示退役数据。控制器代码:
public ActionResult MyAccount()
{
var user = User.Identity.Name;
string sThumbnails = "";
DataSet dsTemplates = new DataSet();
string qryTemplets = "select * from FileInfo where UserName= '" + user + "'";
open_Connection();
SqlDataAdapter daTemplate = new SqlDataAdapter(qryTemplets, conn);
daTemplate.Fill(dsTemplates, "FileInfo");
DataTable dtTemplates = new DataTable();
dtTemplates = dsTemplates.Tables[0];
foreach (DataRow row in dtTemplates.Rows)
{
sThumbnails = sThumbnails + row["FileName"] + row["Date"] + row["Time"] + row["Info"] ;
ViewData["thumbs"] = sThumbnails;
}
close_Connection();
return View();
}
查看代码:
<div id="formleft" style="border-style: solid; border-color: inherit; border-width: 4px; width:550px; height:500px; position:absolute; top: 345px; left: 348px;">
<h2 class="heading" style="text-align: center;">Info</h2><%= ViewData["thumbs"] %> </div>
此代码显示数据但我想以表格格式显示它。
如何以表格格式显示数据?