Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

problem in the rating

$
0
0

hiiii everyone

im trying to do  the rating control ,i want the rating to be stored in the database so i implemented the onchanged event but when i click it nothing added to the database it wont work check the code please

<ajaxToolkit:Rating ID="Rating1" runat="server" AutoPostBack="true" OnChanged="Rating1_Changed"  StarCssClass="Star" WaitingStarCssClass="WaitingStar" EmptyStarCssClass="Star"
    FilledStarCssClass="FilledStar"></ajaxToolkit:Rating>

here is the code behind

protected void Rating1_Changed(object sender, AjaxControlToolkit.RatingEventArgs e)
        {
            string constr = ConfigurationManager.ConnectionStrings[1].ConnectionString;
            using (SqlConnection con = new SqlConnection(constr))
            {
                using (SqlCommand cmd = new SqlCommand("INSERT INTO Rating VALUES (@rating,@id)"))
                {
                    using (SqlDataAdapter sda = new SqlDataAdapter())
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@rating", e.Value);
                        cmd.Parameters.AddWithValue("@id", Request.QueryString["pla"].ToString());
                        cmd.Connection = con;
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }
            }
            Response.Redirect(Request.Url.AbsoluteUri);
        }

  but nothing is happening i dont where is the problem?


Viewing all articles
Browse latest Browse all 5678

Trending Articles