Reputation: 1115
I have an asp.net 4 page with a user control in it. When the user selects a value in a grid inside the user control I would like to update a data source's (in my case a LINQ data source) WHERE clause using a value from the grid. The data source object is in the parent page. The page life cycle loads the parent page before the grid's item command method executes so I am not able to get the selected value.
How can this be done? I would like to do this all server-side if possible.
Upvotes: 1
Views: 206
Reputation:
Create an event in the child page like so:
public event EventHandler DataChanged;
From the child page, call it like this when appropriate:
if (DataChanged != null)
DataChanged(sender, new EventArgs());
Then in the parent page, create a method to be called and attach it like so:
protected void DoSomething(object sender, EventArgs e)
{
}
child.DataChanged += DoSomething;
Oh yeah, I almost forgot. I think you have to set up the event relationship in Page_Init() rather than waiting for Page_Load().
Upvotes: 3