This is a migrated thread and some comments may be shown as answers.

Unexpected Results when RadRatingItem Value=0

2 Answers 31 Views
Rating
This is a migrated thread and some comments may be shown as answers.
Ronnie
Top achievements
Rank 1
Ronnie asked on 08 Jan 2011, 02:25 AM
Hello,

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">
      <Items>
         <telerik:RadRatingItem Value="0"
            HoveredImageUrl="Assets/Collection/Images/Rating/Binary/downh.png"
            HoveredSelectedImageUrl="Assets/Collection/Images/Rating/Binary/downh.png"
            SelectedImageUrl="Assets/Collection/Images/Rating/Binary/downh.png"
            ImageUrl="Assets/Collection/Images/Rating/Binary/down.png"
            ToolTip="No" />
         <telerik:RadRatingItem Value="1"
            HoveredImageUrl="Assets/Collection/Images/Rating/Binary/uph.png"
            HoveredSelectedImageUrl="Assets/Collection/Images/Rating/Binary/uph.png"
            SelectedImageUrl="Assets/Collection/Images/Rating/Binary/uph.png"
            ImageUrl="Assets/Collection/Images/Rating/Binary/up.png"
            ToolTip="Yes" />
      </Items>
</telerik:RadRating>

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,
Ronnie

2 Answers, 1 is accepted

Sort by
0
Tsvetie
Telerik team
answered on 13 Jan 2011, 12:42 PM
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">
    <Items>


Kind regards,
Tsvetie
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.
0
Ronnie
Top achievements
Rank 1
answered on 13 Jan 2011, 09:35 PM
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,
Ronnie
Tags
Rating
Asked by
Ronnie
Top achievements
Rank 1
Answers by
Tsvetie
Telerik team
Ronnie
Top achievements
Rank 1
Share this question
or