Force Calendar Control to "Re-Bind"

There are several posts on this, but I'm still having some issues.

I want to build a web page that allows a user to select a project from a drop down.  When they select the project, my form goes to the database to get all of the due dates associated with the project and I use the DayRender event to populate the calendar.  I can get this to work on the first page load by getting my data in the Page_Load event, then the DayRender event fires and fills the calendar.  How can I get this to work when the user selects a value from a drop down?

I tried this code from another post:  (Code was added to a Button Click event)

        Dim DREg As System.Web.UI.WebControls.DayRenderEventArgs
        Calendar1_DayRender(sender, DREg)

..but this does not work.  The DayRender event gets fired, but the error indicates that the "e" event arg variable has not been created.  How can I solve this?
tfewster949Asked:
Who is Participating?
 
naveenkohliConnect With a Mentor Commented:
You will have to load the Data for your calendar on post back. You can save the DataTable in Session and load it from there on post back.
0
 
naveenkohliCommented:
If you are handling DayRender event then you should be getting this event called during post back too. You should not have to force the call into this event.
If you remove your forced call to dayrender event, Does your calendar show up on post back or not?
0
 
tfewster949Author Commented:
OK, I think I'm getting somewhere.

1) I have a DataTable variable that has scope across the entire page.
2) On Page_Load, I fill the DataTable with data on project schedule dates from the database.  I only do this on the first page load, not on post back.
3) DayRender event then fills the calendar with schedule information.

4) Drop Down contains list of projects with AutoPostBack=TRUE.  When the user selects a new project, the SelectedIndexChanged event fires and it reloads the DataTable with updated information on the newly selected project.

5) DayRend then fires again and the calendar information is updated.

Problem now is that the DayRender event only populates information for the month that is currently visible in the calendar.  When the user selects the next or previous month, I get an error from the DayRender event that the DataTable does not exist.  Does this mean I need to rebuild the DataTable each time the user changes the month?  Can I save the original DataTable in view state?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.