Click here to Skip to main content
14,836,552 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
/* The following styles are for the Rating */
.ratingStar {
font-size: 0pt;
width: 13px;
height: 12px;
margin: 0px;
padding: 0px;
cursor: pointer;
display: block;
background-repeat: no-repeat;

.filledRatingStar {
background-image: url(Images/FilledStar.png);

.emptyRatingStar {
background-image: url(Images/EmptyStar.png);

.savedRatingStar {
background-image: url(Images/SavedStar.png);

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">

<asp:Repeater ID="Repeater1" runat="server">

<%#Container.ItemIndex+1 %>
<asp:Label ID="rvid" runat="server" Text='<%#Eval("rvid") %>'>
  <%#Eval("title") %>  <ajaxToolkit:Rating ID="Rating1" runat="server"
AutoPostBack="true" CurrentRating='<%# Eval("rating") %>' StarCssClass="ratingStar"
WaitingStarCssClass="savedRatingStar" FilledStarCssClass="filledRatingStar" EmptyStarCssClass="emptyRatingStar"


using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["dsn_SQL"].ToString());
SqlCommand cmd = new SqlCommand();
DataTable dt = new DataTable();
protected void Page_Load(object sender, EventArgs e)

private void ShowData()
cmd.Connection = con;
cmd.CommandText = "select * from product_reviews";
cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter(cmd);
if (dt.Rows.Count > 0)
Repeater1.DataSource = dt;

protected void Rating1_Changed(object sender, AjaxControlToolkit.RatingEventArgs e)
AjaxControlToolkit.Rating myRating = (AjaxControlToolkit.Rating)sender;
Label rvid = ((Control)sender).Parent.FindControl("rvid") as Label;

and were is your question?
Member 14209106 10-Apr-19 5:16am
Hello, I've similar challenge. I want the repeater to display rating of each product from the database also, I'm in need of a solution, thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900