RadGrid for ASP.NET

RadGrid Send comments on this topic.
NoRecordsTemplate Property
See Also  Example
Telerik.WebControls Namespace > GridTableView Class : NoRecordsTemplate Property


Gets or sets the template that will be displayed if a GridTableView control is bound to a data source that does not contain any records.

  

 

Namespace: Telerik.WebControls
Assembly: RadGrid (in RadGrid.dll)

Syntax

Visual Basic (Declaration) 
Public Property NoRecordsTemplate As ITemplate
Visual Basic (Usage)Copy Code
Dim instance As GridTableView
Dim value As ITemplate
 
instance.NoRecordsTemplate = value
 
value = instance.NoRecordsTemplate
C# 
public ITemplate NoRecordsTemplate {get; set;}

Return Value

A System.Web.UI.ITemplate that contains the custom content for the empty data row. The default value is a null reference (Nothing in Visual Basic), which indicates that this property is not set.

Example

The following example demonstrates how NoRecordsTemplate can be implemented declaratively:

[ASPX/ASCX]

<rad:RadGrid ID="RadGrid1" runat="server">
<MasterTableView>
<NoRecordsTemplate>
<div style="text-align: center; height: 300px">
<asp:Label ForeColor="RoyalBlue" runat="server" ID="Label1">Currently there are no items in this folder.</asp:Label>
<br />
</div>
</NoRecordsTemplate>
</MasterTableView>
</rad:RadGrid>

The following code snippet demonstrates how the NoRecordsTemplate can be implemented dynamically:

Visual BasicCopy Code
RadGrid1.MasterTableView.NoRecordsTemplate = New NoRecordsTemplate()

Public Class NoRecordsTemplate
    Implements ITemplate

    Public Sub New()
    End Sub

    Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements System.Web.UI.ITemplate.InstantiateIn
        Dim lbl As Label = New Label()
        lbl.ID = "Label1"
        lbl.Text = "Currently there are no items in this folder."
        lbl.ForeColor = System.Drawing.Color.RoyalBlue
        container.Controls.Add(lbl)
    End Sub
End Class
C#Copy Code
RadGrid1.MasterTableView.NoRecordsTemplate = new NoRecordsTemplate();

class NoRecordsTemplate: ITemplate
{
   
public NoRecordsTemplate()
   {
   }
   
   
public void InstantiateIn(Control container)
   {
       Label lbl =
new Label();
       lbl.ID =
"Label1";
       lbl.Text =
"Currently there are no items in this folder.";
       lbl.ForeColor = System.Drawing.Color.RoyalBlue;
       container.Controls.Add(lbl);
   }
}
    

Remarks

You can set the text that will appear in the NoRecordsTemplate through NoMasterRecordsText and NoDetailRecordsText properties.

By default if Items.Count equals 0, GridTableView will render no records message.

If NoRecordsTemplate and NoMasterRecordsText/NoDetailRecordsText are set, the NoRecordsTemplate property has priority.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also