New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Data Binding


RadRating can be easily bound to any of the ASP.NET DataSource controls (SqlDataSource, LinqDataSource, and etc.). All you need to do is set the Rating's DataSourceID property to the ID of the DataSource control.

This Rating control is bound to a SqlDataSource control, and has its ItemBinding.ValueField property is mapped to the "TimesRated" column of the Data Source.


This RadRating control is bound in the code-behind using the RadRating.DataSource property. The Value and ToolTip properties of the Items are mapped to the respective fields of the DataSource, by using the RadRating.ItemBinding.ValueField and RadRating.ItemBinding.ToolTipField properties.


The RadRating provides property, DbValue, that sets the rating value in a database-friendly way. This example shows this property in action.

We have RadRotator bound to a set of images, and for every image there is a Rating control that displays the respective rating.

  • Demo Configurator

Change ToolTipFormatString (move the mouse pointer over the Rating to see the change)

RadRating's Items collection can be populated with data from a given data source. To bound the control to any of the ASP.NET Data Source controls, all you need to set its DataSourceID property to the ID of the respective DataSource control. If you need to programmatically populate the Rating, you should use the RadRating.DataSource property.

The RadRatingItem's ToolTip and the Value property can be mapped to desired columns/fields of the Data Source, through the RadRating.ItemBinding.ToolTipField and RadRating.ItemBinding.ValueField respectively. The RadRating.ItemBinding.ToolTipFormatString should be used to control how data bound to the ToolTip property is displayed.

  • DefaultVB.aspx
  • DefaultVB.aspx.vb
  • styles.css
<%@ Page Language="vb" AutoEventWireup="true" Inherits="Telerik.Web.Examples.Rating.DataBinding.DefaultVB"CodeFile="DefaultVB.aspx.vb"  %>

<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns=''>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link href="styles.css" rel="stylesheet" />
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <telerik:RadAjaxLoadingPanel ID="LoadingPanel1" runat="server" Skin="Sunset" MinDisplayTime="500">
    <div class="demo-containers">
        <div class="demo-container size-thin">
            <telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server" LoadingPanelID="LoadingPanel1">
                    <strong style="padding-bottom: 20px; display: block;">DataSourceID</strong>
                    <telerik:RadRating RenderMode="Lightweight" ID="RadRating3" runat="server" DataSourceID="SqlDataSource1" AutoPostBack="true"
                        OnRate="RadRating_Rate" Skin="WebBlue">
                        <ItemBinding ValueField="TimesRated"></ItemBinding>
                    <asp:Label ID="lblRating" runat="server" ForeColor="Green"></asp:Label>
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TelerikConnectionString %>"
                        SelectCommand="SELECT DISTINCT TOP(7) TimesRated FROM Vehicles WHERE (VehicleTypeID = '1') ORDER BY TimesRated">
                        <strong>RadRating</strong> can be easily bound to any of the ASP.NET DataSource
                        controls (SqlDataSource, LinqDataSource, and etc.). All you need to do is set the
                        Rating's <strong>DataSourceID</strong> property to the ID of the DataSource control.
                        This Rating control is bound to a SqlDataSource control, and has its ItemBinding.<strong>ValueField</strong>
                        property is mapped to the "TimesRated" column of the Data Source.
        <div class="demo-container size-thin">
            <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="LoadingPanel1">
                    <strong style="padding-bottom: 20px; display: block;">RadRating.DataSource</strong>
                    <telerik:RadRating RenderMode="Lightweight" ID="RadRating2" runat="server" Skin="WebBlue" AutoPostBack="true"
                    <asp:Label ID="Label1" runat="server" ForeColor="Green"></asp:Label>
                        This <strong>RadRating</strong> control is bound in the code-behind using the <strong>
                            RadRating.DataSource</strong> property. The <strong>Value</strong> and <strong>ToolTip</strong>
                        properties of the Items are mapped to the respective fields of the DataSource, by
                        using the RadRating.ItemBinding.<strong>ValueField</strong> and RadRating.ItemBinding.<strong>ToolTipField</strong>
        <div class="demo-container size-thin">
                <strong style="padding-bottom: 20px; display: block;">DbValue</strong>
                <telerik:RadRotator RenderMode="Lightweight" ID="rotatorRating" runat="server" Height="175px" ItemHeight="160px"
                    Width="151px" ItemWidth="151px">
                        <asp:Image ID="Image1" runat="server" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "Path") %>'
                            AlternateText='<%# VirtualPathUtility.GetFileName(DataBinder.Eval(Container.DataItem, "Path").ToString()) %>'>
                        <telerik:RadRating RenderMode="Lightweight" ID="RadRating1" runat="server" ItemCount="7" ReadOnly="true" Skin="Simple"
                            DbValue='<%# DataBinder.Eval(Container.DataItem, "Value") %>'>
                    The <strong>RadRating</strong> provides property, <strong>DbValue</strong>, that
                    sets the rating value in a database-friendly way. This example shows this property
                    in action.
                    We have RadRotator bound to a set of images, and for every image there is a Rating
                    control that displays the respective rating.
    <qsf:ConfiguratorPanel ID="demoConfigurator" runat="server">
            <qsf:View Title="RadRating.DataSource Settings">
                    Change <strong>ToolTipFormatString</strong> (move the mouse pointer over the Rating
                    to see the change)
                <asp:RadioButtonList AutoPostBack="true" ID="rbListToolTipFormatString" runat="server"
                    <asp:ListItem Text="None" Value="" Selected="True"></asp:ListItem>
                    <asp:ListItem Text="Rating: {0}" Value="Rating: {0}"></asp:ListItem>
                    <asp:ListItem Text="The Item's ToolTip is '{0}'" Value="The Item's ToolTip is '{0}'"></asp:ListItem>

Support & Learning Resources

Find Assistance