I am building a basic blog module that allows the user to rate the blog posts.
The ratings are submitted via an ajax extension and held in a data table as an INT value.
When I call the ratings onto the page using a variable I would like to calculate the overall average rating.
Could anyone shed some light on how I would go about doing this?
Here is my code:
var rating = from x in db.DT_Control_BlogRatings
where x.Blog_ID == int.Parse(codesnippets.Decrypt(Request["blg"].ToString(), true))
select new
{
x.RatingNo,
x.RatingID,
};
string usercount = rating.Count().ToString();
LB_UserRating.Text = "Currently rated " + usercount + " times";
Many thanks!
1 Answer