I have a usercontrol as my edit form, and a property called DataItem that gets bound, one item of which is called ItemID and is bound to a HiddenField.
<
asp:HiddenField
ID
=
"itemID"
runat
=
"server"
Visible
=
"false"
Value='<%# DataBinder.Eval(Container, "DataItem.ItemID") %>' />
Everything seems good, form renders. I have two controls I call by button click, and in those handlers I can get the value of the HiddenField ItemID to pass its value along in a url.
"&ItemID=" & itemID.Value.ToString() &
The problem comes in when in Page_Load, I want to restrict whether to show these controls or not by the value of ItemID. In Page_Load, itemID.Value is empty, presumably because the page hasn't loaded yet, and while _dataItem seems to exist, it has no fields yet. Is there an event I can tie into to say 'run this after _dataItem has been bound'? There is OnDataBound, but the note on the documentation page says only useful with client side data binding and my solution uses NeedsDataSource.