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

RadRating in RadGrid

Vehicle NameAverage Vehicle RatingTimes Rated
 Page 1 of 8, items 1 to 10 of 75.
Ford 4
Citroen 6
VW 3
Mazda 8
Honda 2
Renault 8
BMW 6
Mercedes 4
Audi 2
Opel 7

This example demonstrates how to incorporate RadRating into RadGrid. This way the user can rate the items loaded in the Grid. You can choose whether or not to allow a single user to rate an item more than once. The example allows an item to be rated only once. The respective Rating control becomes read-only (i.e. RadRating1.ReadOnly = true), after the item has been rated.

Please note that the changes in the data will be persisted per Session only. The data will be reset next time you visit the page.

The user is allowed to rate an item only once. The respective Rating control becomes read-only after the item is rated.
Note: The changes in the data will be persisted per Session only. The data will be reset next time you visit the page.

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • styles.css
<%@ Page Language="c#" AutoEventWireup="true" Inherits="Telerik.Web.Examples.Rating.GridRating.DefaultCS"CodeFile="DefaultCS.aspx.cs"  %>

<%@ Register TagPrefix="sds" Namespace="Telerik.Web.SessionDS" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link href="styles.css" rel="stylesheet" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container no-bg">
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" runat="server" Width="550" AllowPaging="true" AllowSorting="true"
            OnNeedDataSource="RadGrid1_NeedDataSource" PageSize="10" CssClass="gridAuto">
            <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="None" TableLayout="Auto">
                <Columns>
                    <telerik:GridBoundColumn AllowSorting="true" DataField="VehicleName" HeaderText="Vehicle Name"
                        SortExpression="VehicleName" UniqueName="VehicleName">
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn HeaderText="Average Vehicle Rating">
                        <ItemTemplate>
                            <telerik:RadRating RenderMode="Lightweight" ID="RadRating1" runat="server" AutoPostBack="true" Value='<%# Convert.ToDouble(Eval("AverageRating")) %>'
                                OnRate="RadRating1_Rate" Precision="Exact" ReadOnly='<%# Convert.ToBoolean(Eval("isRated")) %>'>
                            </telerik:RadRating>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn AllowSorting="true" DataField="TimesRated" HeaderText="Times Rated"
                        SortExpression="TimesRated" UniqueName="TimesRated">
                    </telerik:GridBoundColumn>
                </Columns>
                <PagerStyle Mode="NumericPages"></PagerStyle>
            </MasterTableView>
        </telerik:RadGrid>
        </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance