Question Datarepeater Checkbox Issue

lynxbct

Member
Joined
Aug 30, 2011
Messages
5
Programming Experience
5-10
This is a follow on from a post I raised yesterday in relation to issues with binding data to a datarepeater. I have gotten to the source of the problem but am not quite sure how to correct it.

I have a checkbox as a control in a datarepeater object. I have an event handler function which handles the checkchanged event for this checkbox and sets the visibility of other fields based on it.
However, the problem I am having is that the event handler function is getting fired when I set the datasource for the datarepeater - hence when the data is being populated. So the event handler function ends up trying to set the visibility of a field that has not been created yet and bombs out with a NullReferenceException error.

Is there a way to stop this event handler being fired when the datarepeater is being populated? I only want this function to be called if that checkbox is changed by the user after the form has loaded.
 
Have just changed the event handler function to act on the Click event of the checkbox rather than the CheckChanged and it appears to work OK.
 
Fixed!!

Found out what the source of the problem was. I had a checkbox and a number of comboboxes in my datarepeater. I had event handlers for all these fields. For example, if the checkbox was ticked I wanted to hide all other fields on that row of the datarepeater. What was happening was that these event handlers were being fired when the datarepeater was databound. As a result, the function was trying to hide fields which had not been created yet.

I have just prevented the functions carrying out the tasks if they are called when the data is binding. Problem Solved!!
 
Back
Top