Unexpected Results when RadRatingItem Value=0

3 posts, 0 answers
  1. Ronnie
    Ronnie avatar
    29 posts
    Member since:
    Oct 2008

    Posted 07 Jan 2011 Link to this post


    I'm not sure if this is the intended results of RadRating or its just in my case, but I have created a Yes/No rating similar to the demo and the problem I encountered was when I set the RadRatingItem to Value="0", then on the initial page_load, the SelectedImageUrl is used as the default image vs ImageUrl.  I'm using the RadRating in a grid and all the grid results produce the same results.

    Here is the RadRating source:
    <telerik:RadRating ID="ratingBinary" runat="server" ItemHeight="20px" ItemWidth="20px"
       Orientation="Horizontal" SelectionMode="Single" AutoPostBack="true" OnRate="ratingBinary_Rate">
             <telerik:RadRatingItem Value="0"
                ToolTip="No" />
             <telerik:RadRatingItem Value="1"
                ToolTip="Yes" />

    The goal was to use 0 & 1 for the rateBinary.Values and convert to bool in the OnRate event.

    Any suggestions are appreciated,
    Thank you,
  2. Tsvetie
    Tsvetie avatar
    1517 posts

    Posted 13 Jan 2011 Link to this post

    Hello Ronnie,
    First, let me explain how the value property of the rating control works. In the case of single selection mode, in case the Value of the rating control is set to a value of one of its items, that item is marked as selected. The default value of the Value property of the rating control is 0. That is why, in case you keep that default value and define a rating item with Value=0, that item will be marked as selected. I hope this makes sense.

    That is why, all I can suggest, is that you set the Value property of the control to a value, different from 0 and 1. For example:
    <telerik:RadRating ID="ratingBinary" runat="server" Orientation="Horizontal" SelectionMode="Single"
        ItemHeight="20px" ItemWidth="20px" CssClass="ratingClass1" AutoPostBack="true" Value="-1">

    Kind regards,
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. Ronnie
    Ronnie avatar
    29 posts
    Member since:
    Oct 2008

    Posted 13 Jan 2011 Link to this post

    Hello Tsvetie,

    Thanks for the response.  After my initial post, I realized that this is after all a 'numeric' rating control.
    I ended up setting the values to 1 and 2 in OnRate and subtracted by one while converting to bool.

    bool wasHelpful = Convert.ToBoolean(ratingBinary.Value - 1);

    Thanks again for your time,
Back to Top