设置 asp .net Rating 控件放在 FormView 控件内时的值

set asp .net Rating control value when it is placed inside FormView control

我有一个如下所示的网页

当运行评级控制代码出现错误Cannot convert type 'string' to 'int' ,有解决这个问题的方法吗?

如何相应地更改 <%#:Item.SessionRating %>

 private int _SessionRating;

   public int SessionRating
        {
            get { return _SessionRating; }
            set { _SessionRating = value; }
        }

完整代码:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="SessionDetails.aspx.cs" Inherits="CodeCamper.UIWebLayer.WebUI.SessionDetails" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
     <script>         
         var changeState = false;
         var counter = 0;
         function changeImage(elementaccess) {
             if (elementaccess == false && changeState == false && document.getElementById("bookmarkimage").getAttribute("src") === "/Images/blue-bookmark.png") {
                 document.getElementById("bookmarkimage").setAttribute("src", "/Images/heart-black.png");
                 document.getElementById("title").innerHTML = "Add To Favorite";
             }
             else if (elementaccess == false && changeState == false && document.getElementById("bookmarkimage").getAttribute("src") === "/Images/heart-black.png") {
                 document.getElementById("bookmarkimage").setAttribute("src", "/Images/blue-bookmark.png");
                 document.getElementById("title").innerHTML = "Add To Favorite";
             }
             else if (counter == 0 && elementaccess == true && (document.getElementById("bookmarkimage").getAttribute("src") === "/Images/heart-black.png" || document.getElementById("bookmarkimage").getAttribute("src") === "/Images/blue-bookmark.png")) {
                 counter = 1;
                 document.getElementById("bookmarkimage").setAttribute("src", "/Images/heart-checked.png");
                 document.getElementById("title").innerHTML = "Remove Favorite";
             }
             else if (counter == 1 && elementaccess == true && document.getElementById("bookmarkimage").getAttribute("src") === "/Images/heart-checked.png") {
                 counter = 0;
                 document.getElementById("bookmarkimage").setAttribute("src", "/Images/blue-bookmark.png");
                 document.getElementById("title").innerHTML = "Add To Favorite";
             }
         }
    </script>

    <div class="generalmargin" style="margin-top: 160px">
        <%--<asp:Button ID="Buttonback" runat="server" Text="" class="button-back"/>--%>

    </div>
    <div style="margin-top: 160px">
        <asp:LinkButton ID="ButtonBack" runat="server" class="btn btn-default btn-md glyphicon glyphicon-backward" Text="" OnClientClick="JavaScript:window.history.back(1);return false;">
        </asp:LinkButton>      
    </div>
     <asp:FormView ID="sessionDetail" runat="server" ItemType="CodeCamper.EntityLayer.Transaction.SessionVO" SelectMethod="GetDetails"  RenderOuterTable="false">
        <ItemTemplate>
            <div>
                <h3><%#: Item.SessionTitle %></h3>
            </div>
            <br />
            <table>
                <tr>
                    <td style="width:25%">                      
                        <label>Track</label>&nbsp;&nbsp;&nbsp;<%#: Item.SessionTrack %><br /><label>Time Slot</label>&nbsp;&nbsp;&nbsp;<%#:Item.SessionTimeSlot %><br /><label>Room</label>&nbsp;&nbsp;&nbsp;<%#:Item.SessionRoom %><br /><label>Level</label>&nbsp;&nbsp;&nbsp;<%#:Item.SessionLevel %><br /><label>Tags</label>&nbsp;&nbsp;&nbsp;<%#:Item.SessionTags %><br /><image src='/Images/photos/<%#:Item.ImagePath%>' />                        
                    </td>
                    <td style="width:75%"><label>Description</label><br />
                        <div class="pre-scrollable"><%#:Item.SessionBio %></div>                       
                    </td>                  
                </tr>
                <tr>
                    <td style="width:25%">                      
                         &nbsp;              
                    </td>
                    <td style="width:75%">
                    <img src='/Images/blue-bookmark.png' ID="bookmarkimage"  onmouseover="changeImage(false);" onmouseout="changeImage(false);" onclick="changeImage(true);" /><br />
                        <br />
                        <cc1:Rating ID="SeesionRating"  runat="server"
                            StarCssClass="Star" WaitingStarCssClass="WaitingStar" EmptyStarCssClass="Star"
                            FilledStarCssClass="FilledStar" ReadOnly="True" CurrentRating=<%#:Item.SessionRating.ToString %>> 
                        </cc1:Rating>
                    </td>                  
                </tr>
            </table>
        </ItemTemplate>
    </asp:FormView>
</asp:Content>

然后试试:

CurrentRating=<%# Item.SessionRating %>