Last post May 11, 2015 10:40 PM by Edwin Guru Singh
None
0 Points
1 Post
May 08, 2015 01:50 AM|prabhavshukla|LINK
I want to use Star Rating Control in listview ..so that users can rate videos... and that rating should get stored into a database.
If anyone can help me with that, i will be very thankful. "If possible through LinqDataSource.....it will be great" :D
ajax starratingcontrol
Star
8544 Points
1376 Posts
May 11, 2015 10:40 PM|Edwin Guru Singh|LINK
hi prabhavshukla, As per your case, the following code snippet which may help you to get the expected result :
Listview with Ajax rating control<asp:ListView ID="lstvw1" runat="server" > <ItemTemplate> <fieldset> <cc1:Rating ID="Rating1" runat="server" CurrentRating='<%# Bind("VideoRating") %>' StarCssClass="ratingStar" WaitingStarCssClass="savedRatingStar" FilledStarCssClass="filledRatingStar" EmptyStarCssClass="emptyRatingStar" OnChanged="Rating1_Changed" ></cc1:Rating> </fieldset> </ItemTemplate> </asp:ListView>
OnChange Eventprotected void Rating1_Changed(object sender, AjaxControlToolkit.RatingEventArgs e) { AjaxControlToolkit.Rating Rating1 = (AjaxControlToolkit.Rating)sender; string productId=;//get corresponding product id here string Rateid = e.value; updateRating(productId,Rateid); //Bind your corresponding datasource to list view here }
Update corresponding value to database :private void updateRating(string ProductId, string Rating) { // put your values into parameters: SqlParameter paramRating = new SqlParameter("@Rating", Rating); SqlParameter paramProductId = new SQlParameter("@ProductId", ProductId); using(SqlCommand cmd = new SqlCommand( "UPDATE Products SET CustomerRating = @Rating WHERE Products.ProductID=@ProductId", new SqlConnection( ConfigurationManager.ConnectionStrings["db1"].ToString()))) { cmd.Parameters.Add(paramRating); cmd.Parameters.Add(paramProductId); cmd.Connection.Open(); cmd.ExecuteNonQuery(); } }
-- with regards, Edwin
None
0 Points
1 Post
AJAX Rating Control in ListView using Database in ASP.net 4.0
May 08, 2015 01:50 AM|prabhavshukla|LINK
I want to use Star Rating Control in listview ..so that users can rate videos... and that rating should get stored into a database.
If anyone can help me with that, i will be very thankful.
"If possible through LinqDataSource.....it will be great" :D
ajax starratingcontrol
Star
8544 Points
1376 Posts
Re: AJAX Rating Control in ListView using Database in ASP.net 4.0
May 11, 2015 10:40 PM|Edwin Guru Singh|LINK
hi prabhavshukla,
As per your case, the following code snippet which may help you to get the expected result :
--
with regards,
Edwin
ajax starratingcontrol
Edwin