在asp.net中的Repeater内部进行Ajax评级

时间:2017-05-28 17:58:02

标签: c# asp.net

我正试图从ajax:Rating内的asp:Repeater获取CurrentRating,但它给了我0。

我在asp.net中的代码:

<asp:Repeater ID="Repeater1" runat="server">
  <ItemTemplate>
   <ajax:Rating ID="Rating1" AutoPostBack="true" runat="server" StarCssClass="Star" 
        WaitingStarCssClass="WaitingStar" EmptyStarCssClass="Star"
        FilledStarCssClass="FilledStar" OnChanged="Save_Location"></ajax:Rating>
  </ItemTemplate>
</asp:Repeater>

在C#背后:

foreach (RepeaterItem rptItem in Repeater1.Items)
{
    Rating ratingControl;
    int rate;

    ratingControl = (Rating)(rptItem.FindControl("Rating1"));
    rate = ratingControl.CurrentRating;

    if (rate != 0)
    {
        //do something
        break;
    }
}

0 个答案:

没有答案