在我的 MVC2 应用程序中,我想以表格形式将日期显示为 5/31/2013 但我得到的是 5/31/2013 12:00:00 AM 我的控制器代码是:
public ActionResult MyAccount()
{
var user = User.Identity.Name;
System.Data.DataTable dt = new System.Data.DataTable();
DataSet ds = new DataSet();
string qry = "select * from Info where UserName= '" + user + "'";
open_Connection();
SqlDataAdapter da = new SqlDataAdapter(qry, conn);
da.Fill(ds);
dt = ds.Tables[0];
foreach (DataRow row in dt.Rows)
{
tableInfo.Add(new TableInfo() { FileName = row[1].ToString(), Date = row[3].ToString() , Time = row[4].ToString(), Info = row[5].ToString() });
}
close_Connection();
return View(tableInfo);
}
模型:
public class TableInfo
{
public string UserName { get; set; }
public string FileName { get; set; }
public string Date { get; set; }
public string Time { get; set; }
public string Info { get; set; }
}