I have a master view with two child views. I would like to have command buttons on the master row which cause an expand to happen to one or the other child tables. When I handle the ItemCommand event, I hide set all detail tables to Visible=False but they are still visible on the output.
I've tried setting the expanded and visibility of the detail tables right within the ItemCommand event like this:
if (e.CommandName == "ExpandSomething")
{
item.Expanded = true;
foreach (var table in MyGrid.MasterTableView.DetailTables)
if (table.Name != "Something")
table.Visible = false;
}
Then I thought maybe the hiding needed to be done later in the event cycle so I tried it like this:
private string _activeChildView = null;
protected void ShowSingleChildTable(string name) //this is called from item command
{
_activeChildView = name;
}
private void Page_PreRender(object sender, EventArgs e)
{
if (_activeChildView != null)
foreach (var table in AdminGrid.MasterTableView.DetailTables)
if (table.Name != _activeChildView)
table.Visible = false;
}
Neither way works - both grids are always visible.
In playing around with different events, I've found that the DataBinding event is the only place that setting the visibility to false works, but unfortunately that fires before the ItemCommand so I can't figure out if a detail button was pressed.