Hi,
I need populated on my MVC form View the TextBox below
@Html.LabelFor(m => m.tDate)
@Html.TextBoxFor(m => m.tDate, "{0:dd/MM/yyyy}", new { @class = "Mytextarea2" })
@Html.ValidationMessageFor(m => m.tDate, "", new { @class = "text-danger" })
Whit value extract from controller
model.tDate = Convert.ToDateTime(GetDateHourById(value).ToString());
private static string GetDateHourById(string value)
{
string sql;
string constr = ConfigurationManager.ConnectionStrings["cn"].ConnectionString;
using (MySqlConnection con = new MySqlConnection(constr))
{
sql = @String.Format(" SELECT ");
sql += String.Format(" tDate ");
sql += String.Format(" FROM `dotable` ");
sql += String.Format(" WHERE tID = @Id;");
using (MySqlCommand cmd = new MySqlCommand(sql))
{
cmd.Connection = con;
cmd.Parameters.AddWithValue("@Id", value);
con.Open();
string name = Convert.ToString(cmd.ExecuteScalar());
con.Close();
return name;
}
}
}
But the TextBox is populed with this value
/Date(1609860060000)/
How to do resolve this?