I want to add a calendar on textbox with time.
and save in database
datatype is datetime in database how to send from .cs page
please provide with example
I want to add a calendar on textbox with time.
and save in database
datatype is datetime in database how to send from .cs page
please provide with example
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jithu ThomasRank #437 · 5.7K reputationPosted Jan 23, 2024, 4:38 AM EST
Backend. for C#
protected void btnSave_Click(object sender, EventArgs e)
{
string selectedDateTime = hiddenField.Value;
string connectionString = "YourConnectionString";
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
string insertQuery = "INSERT INTO YourTable (YourDateTimeColumn) VALUES (@SelectedDateTime)";
using (SqlCommand command = new SqlCommand(insertQuery, connection))
{
command.Parameters.AddWithValue("@SelectedDateTime", DateTime.Parse(selectedDateTime));
command.ExecuteNonQuery();
}
}
}