Does anyone know if you can access the databound event from a databound, say, dropdownlist that is within a FormView EditItemTemplate?
For example, say you have a member update form, and within the EditItemTemplate you have a dropdownlist that binds the CityID to a list of Cities. So I’d like to tap into the databound event for that control in the formview and add a value to the cities.
Also, I know there are other ways to handle the situation. I’m not looking for an alternate solution to this problem, I’d like to know if anyone has been able to do it this way?
Sure! Here’s a way I’ve done it before. Once your
FormViewloads, you can find the DataBound control using theFindControlmethod:Then, you can use the
+=syntax to add the event handler method you’ve written:Then, whenever you call
myDDL.DataBind(), themyDDL_DataBoundmethod will be executed.Edit: Just to be clear – you say “Access the databound event”. That means the method I mentioned (
myDDL_DataBound) needs to look something like this: