Eric Wise

Sponsors

The Lounge

Wicked Cool Jobs

Blogs I Read

Fun & Games

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Page_Load, Grids with Dynamically Controls, and calendars OH MY!!!!

Here's a fun one.  I'm working on a scheduling system for a fortune 500 company.  I'm having a very interesting issue here.

First, I have a datagrid control.  It has a variable number of columns which can change depending on whoever the logged in user's settings are.  In this case let's imagine the header is like this:

Truck Name | Slot 1 | Slot 2 | Slot 3

Now in the data if a truck is already scheduled for a slot, a code shows up.  If the slot is available, I create a link button called Add.  So here's what my grid looks like when loaded in page load (excuse the lack of screenshots)

Truck Name | Slot 1 | Slot 2 | Slot 3

    Truck 1          B      |     D    |  Add

    Truck 1          Add  |    Add |   C

Now, because these add buttons are added dynamically to my grid, their events will not fire unless the grid is bound on each postback in page_load.  The ASP .NET Event model dictates this and it's a commonly accepted fact.

Here's the tricky part.  I have a calendar control on the page that is meant to reload the grid for a different date.  The Calendar control's SelectedDate() property is not updated until after Page_Load.  So for me to get events working properly AND to get the correct date I seem to be forced to load and bind the datagrid twice.  Once in page load and again after the calendar control is updated.  (pre_render, wherever).

There must be a more elegant way!


Posted Thu, Dec 16 2004 9:10 AM by Eric Wise

[Advertisement]

Comments

MAR wrote re: Page_Load, Grids with Dynamically Controls, and calendars OH MY!!!!
on Tue, Aug 16 2005 9:35 AM
Hi ewise

I am facing a very similar problem where I load buttons and checkboxes to a Table dynamically.
Because my Table changes so often I sometimes have to click the button twice. Have you found a solution to your problem?
Devlicio.us