Hello Experts,
I need to retrieve data from my DB to a TextBox Control and when I return it the datetimie data it is returned in this format 10/2/2011 12:00:00. I would like it to just display 10/2/2011 if possible.
The following label beow is what I need formatting help with.
txtDate.Text = data["csch_startdate"].ToString();
protected void RetrieveCourseScheduleToUpdateValues()
{
int csch_id = Convert.ToInt32(Request.QueryString["csch_id"]);
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["HealthCourses"].ConnectionString))
{
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "HealthCourses_RetrieveCourseScheduleByIDForUpdate";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = conn;
cmd.Parameters.AddWithValue("@csch_id", SqlDbType.Int).Value = csch_id;
DataTable dtCourseToUpdate = new DataTable();
SqlDataAdapter adp = new SqlDataAdapter();
try
{
conn.Open();
adp.SelectCommand = cmd;
adp.Fill(dtCourseToUpdate);
if (dtCourseToUpdate != null)
{
DataRow data = dtCourseToUpdate.Rows[0];
hfv_csch_id.Value = data["csch_id"].ToString();
lblCourseNameResult.Text = data["ghaco_name"].ToString();
ddlInstructor.SelectedValue = data["hmi_id"].ToString();
txtDate.Text = data["csch_startdate"].ToString();
txtStartTime.Text = data["csch_starttime"].ToString();
txtEndTime.Text = data["csch_endtime"].ToString();
}
}
catch (Exception ex)
{
ex.Message.ToString();
}
finally
{
conn.Close();
}
}
}