Hiding RadGrid when no rows

2 posts, 0 answers
  1. Derek
    Derek avatar
    119 posts
    Member since:
    Oct 2008

    Posted 19 Mar 2010 Link to this post

    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.
  2. Dimo
    Dimo avatar
    8460 posts

    Posted 23 Mar 2010 Link to this post

    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,
    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.
Back to Top