Tab

ASPxRatingControl.Value Property

Gets or sets the control’s value.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v21.1.dll

Declaration

[DefaultValue(typeof(decimal), "5")]
public decimal Value { get; set; }

Property Value

Type Default Description
Decimal

“5”

A Object value representing the control’s value.

Remarks

Use the Value property to manipulate the control’s value on the server side. Specific ASPxClientRatingControl.SetValue and ASPxClientRatingControl.GetValue methods are useful to specify and obtain the control’s value on the client side.

The Value property synchronizes its value with the number of the control’s filled items. In case the property’s value is a fractional number, use the ASPxRatingControl.FillPrecision property to specify how the items should be filled.

NOTE

The Value property value can’t exceed the control’s items count (the ASPxRatingControl.ItemCount property).

Example

This part of the Voting demo illustrates how to use the ASPxRatingControl‘s ASPxRatingControl.Value property.

Here, the ASPxRatingControl item click initiates a callback on the server within the ASPxClientRatingControl.ItemClick client event. The total rating is calculated as an arithmetic mean for the current user on the server, and stores the control’s value (ASPxRatingControl.Value) by using the ASPxClientRatingControl.SetValue method.

protected void Page_Load(object sender, EventArgs e) {
         ...
         if(!IsCallback) {
             ratingControl.Value = GetRating();
         ...
         }
     }

     protected void cbVoting_Callback(object source, CallbackEventArgs e) {
         ...
         CurrentUserRatingValue = (int)ratingControl.Value;
         e.Result = string.Format("{0} {0:0.##}", GetRating());
     }

     public int? CurrentUserRatingValue { 
         get { return (int?)Session["CurrentUserRatingValue"]; }
         set { Session["CurrentUserRatingValue"] = value; }
     }
     public decimal GetRating() {
        ...
        //rating calculations
        ...
     }
 }
See Also