Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q1 2012 released 04/11/2012
select

Grid / Rating Column

Next database reset in 0 hours, 37 minutes, 22 seconds
Example Configuration
Configure GridRatingColumn:
ItemCount (MAX 10)
SelectionMode
Precision
IsDirectionReversed
AllowRatingInViewMode
Add new recordRefresh
 TitleRatingVotes
 
Star Wars Episode V - The Empire Strikes Back (1980)483
Pulp Fiction (1994)355
The Godfather (1972)368
The Shawshank Redemption (1994)212
The Godfather: Part II (1974)329
Schindler's List (1993)412
12 Angry Men (1957)313
The Usual Suspects (1995)295
The Matrix (1999)455
Se7en (1995)385

  • GridRatingColumn displays a RadRating control both in view and edit mode, giving your users the functionality to view or modify the rating of your data items. GridRatingColumn binds to your data source throuh its DataField property specifying the name of a numeric field from your data. The column supports automatic data source operations with ASP.NET data source controls. You can additionally customize the behavior of the rating controls using the following properties:

    • ItemCount - gets or sets the number of items RadRating shows. The default value is 5.
    • SelectionMode - gets or sets the SelectionMode (Single or Continuous) property of the RadRating control.
    • Precision - gets or sets the Precision property of the RadRating control (whether users can select an exact portion, half or whole item).
    • IsDirectionReversed - gets or sets the IsDirectionReversed property of the RadRating control.
    • AllowRatingInViewMode - gets or sets a value indicating whether users are allowed to rate data items in view mode. The default value is false (RadRating is rendered ReadOnly in view mode).

    To retrieve or modify the value of the rating control in a given RadGrid item programmatically, you can use two options:

    1. Find the RadRating control programmatically. The ID of the rating control in each column cell is Rating_[ColumnUniqueName], where [ColumnUniqueName] is the UniqueName of the GridRatingColumn instance.
    2. Use the GridRatingColumnEditor instance for your rating column. This column editor type provides the readonly Value property that returns the current rating value, and the RatingControl property, returning a reference to the RadRating control in the current grid item.

    As the GridRatingColumn renders a RadRating control both in view and edit mode, the GridRatingColumnEditor is always initialized. This means that you can access the editor using:

    GridEditableItem.EditManager.GetColumnEditor([ColumnUniqueName])

    even when the item is not in edit mode, including when you want to access a modified rating value on postback with AllowRatingInViewMode = true.

    Similary, GridEditableItem.ExtractValues(Hashtable values) will also return the modified rating value both in view and edit mode.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="VB" AutoEventWireup="false" CodeFile="DefaultVB.aspx.vb" Inherits="Telerik.GridExamplesVBNET.GeneralFeatures.GridRatingColumn.DefaultVB" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="telerik" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="sds" Namespace="Telerik.Web.SessionDS" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <telerik:HeadTag runat="server" ID="Headtag2"></telerik:HeadTag>
        <!-- custom head section -->
        <!-- end of custom head section -->
        <style type="text/css">
            .bigModuleBottom table td
            {
                padding: 1px 5px;
            }
            
            #ResultPanel b
            {
                color: Red;
            }
        </style>
    </head>
    <body class="BODY">
        <form id="mainForm" runat="server">
        <telerik:Header runat="server" ID="Header1" NavigationLanguage="VB" ShowDbResetTimer="true">
        </telerik:Header>
        <telerik:RadScriptManager ID="ScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <!-- content start -->
        <telerik:ConfiguratorPanel ID="ConfiguratorPanel1" runat="server" Expanded="true">
            <div class="title">
                Configure GridRatingColumn:
            </div>
            <asp:Panel ID="ResultPanel" runat="server" Style="float: right; width: 250px">
            </asp:Panel>
            <table>
                <tr>
                    <td>
                        ItemCount (MAX 10)
                    </td>
                    <td>
                        <telerik:RadNumericTextBox ID="ItemCountBox" runat="server" Value="5" NumberFormat-AllowRounding="false"
                            NumberFormat-DecimalDigits="0" Style="margin-left: 10px">
                        </telerik:RadNumericTextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        SelectionMode
                    </td>
                    <td>
                        <asp:RadioButtonList ID="SelectionModeList" runat="server" RepeatColumns="2">
                            <asp:ListItem Text="Single" Value="Single"></asp:ListItem>
                            <asp:ListItem Text="Continuous" Value="Continuous" Selected="True"></asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
                <tr>
                    <td>
                        Precision
                    </td>
                    <td>
                        <asp:RadioButtonList ID="PrecisionList" runat="server" RepeatColumns="3">
                            <asp:ListItem Text="Exact" Value="Exact"></asp:ListItem>
                            <asp:ListItem Text="Half" Value="Half"></asp:ListItem>
                            <asp:ListItem Text="Item" Value="Item" Selected="True"></asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
                <tr>
                    <td>
                        IsDirectionReversed
                    </td>
                    <td>
                        <asp:RadioButtonList ID="ReversedList" runat="server" RepeatColumns="2">
                            <asp:ListItem Text="True" Value="True"></asp:ListItem>
                            <asp:ListItem Text="False" Value="False" Selected="True"></asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
                <tr>
                    <td>
                        AllowRatingInViewMode
                    </td>
                    <td>
                        <asp:RadioButtonList ID="RateInViewModeList" runat="server" RepeatColumns="2">
                            <asp:ListItem Text="True" Value="True"></asp:ListItem>
                            <asp:ListItem Text="False" Value="False" Selected="True"></asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
    <asp:Button ID="ApplyButton" runat="server" Text="Apply" Width="120px" OnClick="ApplyButton_Click"
    CssClass="button" />

                    </td>
                </tr>
            </table>
        </telerik:ConfiguratorPanel>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                        <telerik:AjaxUpdatedControl ControlID="ResultPanel" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="ApplyButton">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="false"
            Width="700px" AllowSorting="true" AllowFilteringByColumn="true" AllowAutomaticUpdates="true"
            AllowAutomaticInserts="true" OnItemCommand="RadGrid1_ItemCommand" OnItemInserted="RadGrid1_ItemInserted"
            OnItemUpdated="RadGrid1_ItemUpdated" OnItemCreated="RadGrid1_ItemCreated">
            <MasterTableView DataKeyNames="ID" CommandItemDisplay="Top" Width="100%">
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditColumn">
                    </telerik:GridEditCommandColumn>
                    <telerik:GridBoundColumn DataField="ID" HeaderText="Rank" ReadOnly="true" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Title" HeaderText="Title" FilterControlWidth="80%">
                    </telerik:GridBoundColumn>
                    <telerik:GridRatingColumn DataField="Rating" HeaderText="Rating">
                        <HeaderStyle Width="250px" />
                    </telerik:GridRatingColumn>
                    <telerik:GridButtonColumn ButtonType="PushButton" CommandName="UpdateRating" ButtonCssClass="button"
                        Visible="false" UniqueName="UpdateColumn" Text="Update">
                        <HeaderStyle Width="50px" />
                    </telerik:GridButtonColumn>
                    <telerik:GridNumericColumn DataField="Votes" HeaderText="Votes" FilterControlWidth="30px"
                        DataType="System.Int32">
                        <HeaderStyle Width="80px" />
                    </telerik:GridNumericColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" DataSourceMode="DataSet" ConnectionString="<%$ ConnectionStrings:TelerikConnectionString %>"
            SelectCommand="SELECT [ID], [Title], [Rating], [Votes] FROM [MovieRatings]" UpdateCommand="UPDATE [MovieRatings] SET [Title] = @Title, [Rating] = @Rating, [Votes] = @Votes WHERE [ID] = @ID"
            InsertCommand="INSERT INTO [MovieRatings] ([Title], [Rating], [Votes]) VALUES (@Title, @Rating, @Votes)">
            <UpdateParameters>
                <asp:Parameter Name="Title" Type="String" />
                <asp:Parameter Name="Rating" Type="Decimal" />
                <asp:Parameter Name="Votes" Type="Int32" />
                <asp:Parameter Name="ID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="Title" Type="String" />
                <asp:Parameter Name="Rating" Type="Decimal" />
                <asp:Parameter Name="Votes" Type="Int32" />
            </InsertParameters>
        </asp:SqlDataSource>
        <!-- content end -->
        <telerik:Footer runat="server" ID="Footer1"></telerik:Footer>
        </form>
    </body>
    </html>

Get more than expected!

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2012 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451