Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 513793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:27:31+00:00 2026-05-13T07:27:31+00:00

I have an application with ajax star rating but when i am assigning value

  • 0

I have an application with ajax star rating but when i am assigning value to CurrentRating from datatable then it showing error of “Specified cast is not valid”.

I am using this code.

<asp:TemplateField HeaderText="Rating" SortExpression="CustomerRating">
                    <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "CustomerRating")%>'></asp:Label></a>
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                            <ContentTemplate>
                                <cc1:Rating ID="Rating1" runat="server"   CurrentRating='<%# Bind("CustomerRating") %>'  
                                StarCssClass="ratingStar"
                                WaitingStarCssClass="savedRatingStar"
                                FilledStarCssClass="filledRatingStar"
                                EmptyStarCssClass="emptyRatingStar"
                                >
                        </cc1:Rating>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </ItemTemplate>
                </asp:TemplateField>

Then its showing error CurrentRating='<%# Bind("CustomerRating") %>'.

I am taking refrence from these sites.

asp.net forum
Code Project

Same thing working on Code project.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:27:31+00:00Added an answer on May 13, 2026 at 7:27 am

    The problem is most likely that the CustomerRating property of your data item is not of the correct data type. Rating expects an int. The Databinder does use reflection and attempts to automatically handle type conversions, but it has limits.

    Unfortunatly there isn’t enough information in your qustion to know what the actual runtime type of CustomerRating is, so I can’t say why it can’t be cast. My advise would be to explicitly cast or convert the property like so:

    CurrentRating='<%# (string)Bind("CustomerRating") %>'
    CurrentRating='<%# Bind("CustomerRating").ToString() %>'
    CurrentRating='<%# (int)Bind("CustomerRating") %>'
    

    If you can’t convert it simply, or just need to get a debugger on it so you can figure out what the type is you can call out to a custom method in your code-behind instead (and you can attach a debugger there to so you can see the runtime type of the item:

    CurrentRating='<%# MyCustomMethod(Eval("CustomerRating")) %>'
    
    in code behind:
    
    public string MyCustomMethod(object customerRating)
    {
        string rValue = ... //do whatever you need to do to customerRating to get a string out of it
        // good place to set a breakpoint you you can examine what type customerRating actually is so you can figure out how best to convert it to something databinding can use
        return rValue;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple ajax application From this, a popup is launched, with a
I have a web application that uses AJAX to grab JSON data from the
I have an AJAX application which has used CSS divs to create panels on
I have an application that uses AJAX liberally. I have several places where a
I have application that brings response via Ajax and creates 5-20 new jQuery click
I have a basic ajax application, which will not work, instead the php code
I have a small AJAX application, written in PHP that I did not secure
I have an application in which most requests are submitted via AJAX, though some
I'm building an ajax application and I have a choice to make on how
I have an application that posts data to a php script through jquery's ajax

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.