5 Answers, 1 is accepted

Try the following code snippet to achieve the desired scenario.
CS:
protected void RadGrid1_PreRender(object sender, EventArgs e) |
{ |
int RowCount= RadGrid1.MasterTableView.Items.Count; |
if (RowCount == 0) |
{ |
RadGrid1.Visible = false; |
} |
else |
RadGrid1.Visible = true; |
} |
You can also go through the following help article.
Visible/Invisible conventions
Thanks
Shinu.

if i set a break point on this and comment out the if logic - i run the page - initally nothing is bound from an object datasource - it steps through it and i can mouse over to seee that rowcount = 0 - so far so good - when i select something from the tree view and step through it stops and i can determine that the rowcount = 27 - but that's only when the if logic is commented out - if i uncomment the if logic and select something from the tree view - it does not step through this block like it never gets called. I've tried it from both within the radajax panel and out of it. please advise.
protected
void RadGrid2_DataBound(object sender, EventArgs e)
{
int rowcount = RadGrid2.MasterTableView.Items.Count;
if (rowcount < 1)
{
RadGrid2.Visible = false;
}
else
{
RadGrid2.Visible = true;
}
}

How do you bind your RadGrid? Please see if you can move all RadGrid-binding code to the NeedDataSource event and only set the data source for the respective tree view item. Then implement the below code snippet in RadGrid's PreRender event. Please share with us your observations.
Sincerely yours,
Veli
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

if i do this - it doesn't showand the event is never called
int RowCount= RadGrid1.MasterTableView.Items.Count; |
if (RowCount == 0) |
{ |
RadGrid1.Visible = false; |
} |
else |
RadGrid1.Visible = true; |
int RowCount= RadGrid1.MasterTableView.Items.Count; |
//if (RowCount == 0) |
//{ |
// RadGrid1.Visible = false; |
//} |
//else |
// RadGrid1.Visible = true; |