Is it possible to select date from the calendar and put the date to the detailsview?
-
The subject is abit incorrect. Let me describe briefly; I am doing a project in .NET 2.0. C#. I have DetailsView control where user can add date and occasion to the database, thus display it in a gridview. But I wish that user can select the date from the calendar instead of typing. What is the correct syntax to write the code when the date is selected from the calendar?
protected void Calendar1_SelectionChanged(object sender, EventArgs e) { //DetailsView1. = Calendar1.SelectedDate.ToString("dd MMM yyyy"); }
the source from design view thanks in advance. Much appreciated. -
The subject is abit incorrect. Let me describe briefly; I am doing a project in .NET 2.0. C#. I have DetailsView control where user can add date and occasion to the database, thus display it in a gridview. But I wish that user can select the date from the calendar instead of typing. What is the correct syntax to write the code when the date is selected from the calendar?
protected void Calendar1_SelectionChanged(object sender, EventArgs e) { //DetailsView1. = Calendar1.SelectedDate.ToString("dd MMM yyyy"); }
the source from design view thanks in advance. Much appreciated.Hi there. One suggestion is to substitute a TemplateField for your date's BoundField, add a TextBox and Calendar control to the EditTemplate, then use something like this for code:
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
// use the textbox's ID for "TextBox1" below"
TextBox tb = (TextBox)DetailsView1.FindControl("TextBox1")
tb.Text = Calendar1.SelectedDate.ToString("dd MMM yyyy");
} -
Hi there. One suggestion is to substitute a TemplateField for your date's BoundField, add a TextBox and Calendar control to the EditTemplate, then use something like this for code:
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
// use the textbox's ID for "TextBox1" below"
TextBox tb = (TextBox)DetailsView1.FindControl("TextBox1")
tb.Text = Calendar1.SelectedDate.ToString("dd MMM yyyy");
}Hey thanks Mike!
Mike Ellison wrote:
add a TextBox and Calendar control to the EditTemplate
I just add the calendar control to the webform as usual and it works pretty fine. I hope it does not have any further errors.
Another Genius solving my question