I would like to access a calendar control through c# for when a gridview row is edited. However, I am unsure of how to access this through C# behind.
I would like to do the following:
cal_SelectionChanged(object sender, EventArgs e)
{
date = cal.SelectedDate
blah blah...
}
However, as the control is in the gridview edit template, I cannot find a way to access this to C#, compared to if the calendar was just an element on a normal asp.net page.
Thanks
As you appear to be aware, controls within
Templatebased controls (such as<asp:Repeaters>) cannot be accessed directly as you would a control placed directly into a page / usercontrol / masterpage. It is possible to find it using the “FindControl” on the specific item within the control, but there should be an easier way…In this case you should be able to set a
SelectionChangedevent handler on the calendar control to the function in your code-behind. (This is assuming you’re using the inbuilt Calendar control) Something like…When an event such as this is called, the object that caused the event (in this case the calendar control) is passed into the function through the
senderparameter.This means that instead of trying to work out which calendar was clicked, you simply can do this…