<asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                                    
                                                    <ContentTemplate>
                                                   
                                                <div style="width: 100%; padding-top: 1em">
                                                    <img src="Abme/img/rating.png" alt="view" height="25px" width="25px" style="float: left" />
                                                    <asp:Rating ID="Rating1" OnChanged="OnRatingChanged" runat="server"
                                                        StarCssClass="Star" WaitingStarCssClass="WaitingStar" EmptyStarCssClass="Star"
                                                        FilledStarCssClass="FilledStar"></asp:Rating>
                                                    <asp:Label ID="lblRatingStatus" runat="server" Text=""></asp:Label>
                                                </div></ContentTemplate></asp:UpdatePanel>
My ajax rating panel
 protected void OnRatingChanged(object sender, RatingEventArgs e)
    {
        SqlConnection con = new SqlConnection(connStr);
        SqlCommand cmd = new SqlCommand("Insert into rating(rating,postid) values(@rate,@pi)", con);
        cmd.Parameters.AddWithValue("@rate", e.Value);
        cmd.Parameters.AddWithValue("@pi", Request.QueryString["ID"]);
        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();
DataTable dt = this.GetData("SELECT ISNULL(AVG(rating), 0) AverageRating, COUNT(rating) RatingCount FROM rating where postid = '" + Request.QueryString["ID"] + "'");
            foreach (RepeaterItem item in Repeater1.Items)
            {
                Label lbl = item.FindControl("pid") as Label;
               Label lab = item.FindControl("lblRatingStatus") as Label;
                lab.Text = string.Format("{0} Users have rated. Average Rating {1}", dt.Rows[0]["RatingCount"], dt.Rows[0]["AverageRating"]);
                AjaxControlToolkit.Rating r1 = item.FindControl("Rating1") as AjaxControlToolkit.Rating;
                r1.CurrentRating = Convert.ToInt32(dt.Rows[0]["AverageRating"]);
            }
       }
  private DataTable GetData(string query)
    {
        DataTable dt = new DataTable();
        using (SqlConnection con = new SqlConnection(connStr))
        {
            using (SqlCommand cmd = new SqlCommand(query))
            {
                using (SqlDataAdapter sda = new SqlDataAdapter())
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Connection = con;
                    sda.SelectCommand = cmd;
                    sda.Fill(dt);
                }
            }
            return dt;
        }
    }
The rating value get inserted to database async but updated rating is not displayed after update. I have to refresh page in order to display updated ratings.