ranuvishwakarma 0 Newbie Poster

hello,plz tell me how to rate a particular video on average bases and after calculating average how to show that in aspx page;

protected void ratechange(object sender, AjaxControlToolkit.RatingEventArgs e)
    {
        // string k = Rating1.CurrentRating.ToString();
        int rate = int.Parse(e.Value.ToString());
        Response.Write(e.Value);
        count++;
        Session.Add("ratecount", e.Value);
        Session.Add("countuser", count++);




    }
    protected void Advertisedatagrid_ItemCommand(object source, DataGridCommandEventArgs e)
    {
        int ct = int.Parse(Session["ratecount"].ToString());

        if (e.CommandName == "btn")
        {

            Label label1 = new Label();
            label1 = (Label)e.Item.FindControl("lb");

            cmd6.CommandText = "select  views from Video_detail where video_id='" + label1.Text + "'";
            cmd6.Connection = dl.CheckConnection();
            da3.SelectCommand = cmd6;
            da3.Fill(dt1);
            cmd6.ExecuteReader();
            for (int i = 0; i < dt1.Rows.Count; i++)
            {
                if (dt1.Rows[i]["views"] == null)
                {
                    cmd3.CommandText = "insert into Video_detail(video_id,rank1,views)values(@vd,@rnk,@vws)";
                    cmd3.Connection = dl.CheckConnection();
                    cmd3.Parameters.AddWithValue("@vd", label1.Text);
                    cmd3.Parameters.AddWithValue("@rnk", Session["ratecount"].ToString());
                    cmd3.Parameters.AddWithValue("@vws", ++count);
                    cmd3.ExecuteNonQuery();
                    string r = Session["ratecount"].ToString();
                    int r1 = int.Parse(r);
                    int avg = r1 / count;
                }

                else
                {

                    cmd4.CommandText = "update video_detail set rank1= (rank1 + '" + ct + "') ,views= views+1  where video_id='" + label1.Text + "'";
                    cmd4.Connection = dl.CheckConnection();
                    cmd4.ExecuteNonQuery();
                }
            }

            cmd5.CommandText = "select * from Video_detail";
            cmd5.Connection = dl.CheckConnection();
            da2.SelectCommand = cmd5;
            da2.Fill(dt);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i]["video_id"].ToString() == label1.Text)
                {
                    int p = int.Parse(dt.Rows[i]["rank1"].ToString());
                    int cut = int.Parse(dt.Rows[i]["views"].ToString());
                    int avg = ct + p;
                    int average = avg / ++cut;
                    
                
                    if (average > 1 && average <= 3)
                    {
                        if (average > 4 && average <= 7)
                        {
                            if (average > 8 && average <= 10)
                            {
                            ....
                            }
                            else
                            {

                            }


                        }
                        else
                        {

                        }
                    }
                }


            }
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.