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

hide grid when no records

3 Answers 238 Views
Grid
This is a migrated thread and some comments may be shown as answers.
newbie
Top achievements
Rank 1
newbie asked on 06 Mar 2009, 02:01 AM
i do not want to display the grid when there are no records found.

However, currently if there are no records it shows a thin line. How can i get rid of that?

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Mar 2009, 04:34 AM
Hi,

Try the following code snippet in order to hide the RadGrid when there's no records.

CS:
protected void RadGrid1_PreRender(object sender, EventArgs e)  
{  
    if (RadGrid1.MasterTableView.Items.Count == 0)  
    {  
        RadGrid1.Visible = false;  
    }          

Thanks,
Princy.
0
newbie
Top achievements
Rank 1
answered on 06 Mar 2009, 06:53 PM
I am binding my grid in another function and not in the needdatasource event.
This code always renders my grid as visible=false.
0
Sebastian
Telerik team
answered on 07 Mar 2009, 08:24 AM
Hi newbie,

Can you please check whether passing an empty data source for the grid produces the desired result for you:

C#
<GridInstance>.DataSource = new Object[0];

VB.NET
<GridInstance>.DataSource = new Object(){}

This should ensure that the NoRecords template/message will be displayed.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
newbie
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
newbie
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or