I am using the AJAX Rating Control inside a ListView control, When I run the page it throws the error 'Specified cast is not valid'
Here Is the code
(SELECT[prod].[prod_id],[prod].[prod_name],AVG([rates].[prod_rating]) AS[prod_rating] FROM [p1_shop] [pd] LEFT JOIN[prod_rating] [rate] ON [prod].[prod_id] = [rate].[prod_id];
.aspx Code
<asp:ListView ID="product_list" runat="server" EnableTheming="False">
<ItemTemplate>
<cc1:Rating ID="Rating1" runat="server" currentrating='<%#Eval("rest_rating")%>' OnChanged="Rating1_Changed"
StarCssClass="Star" WaitingStarCssClass="WaitingStar" EmptyStarCssClass="Star"
FilledStarCssClass="FilledStar">
</cc1:Rating>
</ItemTemplate>
</asp:ListView>
Can you try implementing Math.Floor in your code with prod_rating because in your SQL query line you are taking data as prod_rating, check this line
AVG([rates].[prod_rating]) AS[prod_rating]
So try this code, if your value is not null and you are getting some Float Value
CurrentRating='<%# Math.Floor(Eval("prod_rating")) %>'
Or if that doesn't work check this link
In the above link there is a post for Ajax Rating in Grid View(not in list view but it may help)
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly