Using the EmptyMessage Property

The EmptyMessage property lets you specify a string that will appear when the RadListBox contains no items.

EmptyMessage property

Setting the EmptyMessage server-side

protected void Page_Load(object sender, EventArgs e)
    RadListBox1.EmptyMessage = "No items added";
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    RadListBox1.EmptyMessage = "No items added"
End Sub 

Setting the EmptyMessage inline

<telerik:RadListBox RenderMode="Lightweight" ID="RadListBox2" runat="server"
    EmptyMessage="No items added">

Controlling the appearance of the EmptyMessage text

To control the appearance of the EmptyMessage text you can add and change this CSS rule:

<style type="text/css">
    div.RadListBox .rlbEmptyMessage
        font-weight : bold;

In addition you can define your own template on how the empty message should look like by using the <EmptyMessageTemplate> tag. Just like the ItemTemplate you can place any html / controls in it and it will be shown when the RadListBox is empty. Here is an example:

<telerik:RadListBox RenderMode="Lightweight" ID="RadListBox1" runat="server"
       <telerik:RadListBoxItem Text="Banana" />
       <telerik:RadListBoxItem Text="Apple" />
       <telerik:RadListBoxItem Text="Grapefruit" />
<telerik:RadListBox RenderMode="Lightweight" ID="RadListBox2" runat="server"
   Height="180px" >
       <img src="empty-cart.png" alt="No items selected">

And here is the result:

Applying the EmptyMessageTemplate

See Also

In this article
Not finding the help you need? Improve this article