I
Iain Porter
Hi all,
I have a usercontrol (a textbox with dropdown calendar that fills the
textbox with the selected date) that I implement in a datagrid in a webform.
On first loading the page, the datagrid's visibility is set to 'false', and
so the UC depCal is not rendered on the page. Hence the following code in
the InitializeComponent() method causes an error:
this.depCal.DateChanged += new
custCalendar.DateChangedEventHandler(this.depCal_DateSet);
The error is: 'Object reference not set to an instance of an object'
Hence I think what I need to do is check for the existance of the control
depCal on the page before exectuing the above code snippet. I tried the
code below, again in the InitializeComponent() method, but it didn't work.
Even when the Datagrid and hence the control depCal is visible on the page,
I never get inside the IF statement.
if ( depCal != null ) {
this.depCal.DateChanged += new
custCalendar.DateChangedEventHandler(this.depCal_DateSet);
}
Can you tell me if I'm approaching the problem from the right angle, and how
to solve it? Thanks in advance for your help,
Iain
I have a usercontrol (a textbox with dropdown calendar that fills the
textbox with the selected date) that I implement in a datagrid in a webform.
On first loading the page, the datagrid's visibility is set to 'false', and
so the UC depCal is not rendered on the page. Hence the following code in
the InitializeComponent() method causes an error:
this.depCal.DateChanged += new
custCalendar.DateChangedEventHandler(this.depCal_DateSet);
The error is: 'Object reference not set to an instance of an object'
Hence I think what I need to do is check for the existance of the control
depCal on the page before exectuing the above code snippet. I tried the
code below, again in the InitializeComponent() method, but it didn't work.
Even when the Datagrid and hence the control depCal is visible on the page,
I never get inside the IF statement.
if ( depCal != null ) {
this.depCal.DateChanged += new
custCalendar.DateChangedEventHandler(this.depCal_DateSet);
}
Can you tell me if I'm approaching the problem from the right angle, and how
to solve it? Thanks in advance for your help,
Iain