Would a call to a database be called if you put the databind method in the PreRender event of a listbox and the listbox was rendered on the screen for example? This is a specific example regarding a listbox, but basically does code in PreRender only get called if the control is rendered on the screen. If this is so, is it good practice to put code into PreRender such as databinding?
Share
edit: you just changed your question, I think the answer is still yes… but the following still applies:
The
PreRenderevent of thelistboxwill only fire if the control is set toVisible=trueon the page.So if you do your
DataBind(and associated database calls) in thePreRenderit will not call your database if it is set toVisible=False.You can test this quite easily by sticking a break point in the
PreRenderand changing the visibility of the control in the HTML.