Hi all
I'm working with a user control (one panel with a Button
and a DropDownList
) in my ASP.NET application, that is triggered by a GridView
. An ID of one record is passed as a CommandArgument
each time a button in the GridView
is clicked, and my control is displayed via the RowCommand
event handler:
myControl.CurrentID = Guid.NewGuid(); // instead a real GUID is passed
My control has a DropDownList
(dynamically populated) and a save button. I do need to populate my DropDownList
, select the current value. When the used clicks save, I need to save the new value.
My issues with this:
- In the control's
Page_Load
theCurrentID
is still empty, as it's populated later on in the lifecycle. What's the most elegant way to handle this in the correct order. UsingPreRender
instead...? - How can I distinguish Page_Load invoked by my save button or by the outer page's Grid?
IsPostBack
does not help, since theRowCommand
event is a PostBack too, obviously. - In general: What are the best practices here? I'm pretty confused at the moment, not sure whether there's a simple and clear solution that I just don't see :)
Thanks for any idea!
Cheers Matthias