Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datarepeater Control Question

Status
Not open for further replies.

Mighty

Programmer
Feb 22, 2001
1,682
0
0
US
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?

Mighty
 
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.

Mighty
 
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!!

Mighty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top