locked
Ajax rating control in gridview RRS feed

  • Question

  • I am trying to implement a rating system. I am using visual studio 2013 c# website. I keep receiving this same error and don't know what is causing it.

    System.InvalidCastException: Specified cast is not valid.
    Line 45:                     <cc1:Rating ID="Rating"

    This is the front end of my code I have used a gridview tool with ajax rating inside it as I am bringing in a lot of data from my access 2007 database which is connected.

    I have one table called machine in my database which has the fields; id ,make ,type ,manufacturer ,customer rating ,image and rating.

    this is the front end of my code for the gridview.

    <cc1:ToolkitScriptManagerID="ToolkitScriptManager1"runat="server">

              

    </cc1:ToolkitScriptManager>

       

    <asp:GridViewID="gvwMake"runat="server"DataKeyNames="MachineID"


               

    BackColor="White"BorderColor="#CCCCCC"BorderStyle="None"BorderWidth="1px"CellPadding="3"AllowPaging="True"OnSelectedIndexChanged="gvwMake_SelectedIndexChanged">

            

    <FooterStyleBackColor="White"ForeColor="#000066"/>

               

    <HeaderStyleBackColor="#006699"Font-Bold="True"ForeColor="White"/>

              

    <PagerStyleBackColor="White"ForeColor="#000066"HorizontalAlign="Left"/>

              

    <RowStyleForeColor="#000066"/>

              

    <SelectedRowStyleBackColor="#669999"Font-Bold="True"ForeColor="White"/>

              

    <SortedAscendingCellStyleBackColor="#F1F1F1"/>

              

    <SortedAscendingHeaderStyleBackColor="#007DBB"/>

              

    <SortedDescendingCellStyleBackColor="#CAC9C9"/>

              

    <SortedDescendingHeaderStyleBackColor="#00547E"/>

             

    <Columns>

                   

    <asp:BoundFieldDataField="Make"HeaderText="Make"/>

                  

    <asp:ImageFieldDataImageUrlField="Image"></asp:ImageField>

                 

    <asp:TemplateFieldHeaderText="Machine Rating">

                 

    <ItemTemplate>

                     

    <cc1:RatingID="Rating"

                         

    AutoPostBack="true"OnChanged="OnRatingChanged"runat="server"

                          

    StarCssClass="Star"WaitingStarCssClass="WaitingStar"EmptyStarCssClass="Star"

                          

    FilledStarCssClass="FilledStar"CurrentRating='<%#Eval("Rating") %>'>

                       

    </cc1:Rating>

       

    </ItemTemplate>

    </

    asp:TemplateField>

    </

    Columns>

    </

    asp:GridView>


    Tuesday, March 18, 2014 3:58 PM