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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jithu ThomasPosted Jan 23, 2024, 9:38 AM
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();
}
}
}