This is a migrated thread and some comments may be shown as answers.

Hiding RadGrid when no rows

1 Answer 183 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Derek
Top achievements
Rank 1
Derek asked on 20 Mar 2010, 02:16 AM
I have a series of Radgrids (linked to Objectdatasources), and I'm wondering if there is a way to detect and *not show* a radgrid if that data source has no rows.

There are 5 different Radgrids, and typically for any specific parent item no more than 2 or 3 will have any content, but it always changes. hence I'd like to show the grid if there is any data, hide it otherwise.

Any and all suggestions are appreciated.

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 23 Mar 2010, 05:35 PM
Hi Derek,

You can check whether a particular RadGrid has data items in the control's PreRender event handler and set Visible = false:

protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    RadGrid grid = sender as RadGrid;
    if (grid.MasterTableView.Items.Count == 0)
    {
        grid.Visible = false;
    }
}


Best wishes,
Dimo
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Derek
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or