1

我在我的 Gridview 中添加了一个 Ajax 评级控件,如下所示:

  <asp:BoundField DataField="Wrms_QueryId" HeaderText="Warms_QueryId" ReadOnly="True" SortExpression="Wrms_QueryId" />
            <asp:TemplateField HeaderText="Favourites">
                <ItemTemplate>
                    <asp:Rating ID="Rating1" runat="server" AutoPostBack="true"  CurrentRating='<%# Bind("num") %>' MaxRating="3" RatingAlign="Horizontal"
                        RatingDirection="LeftToRightTopToBottom" StarCssClass="ratingStar" WaitingStarCssClass="savedRatingStar"
                        FilledStarCssClass="filledRatingStar" EmptyStarCssClass="emptyRatingStar" Tag='<%# Bind("Wrms_QueryId")%>' OnChanged="Rating1_Changed">
                    </asp:Rating>
                </ItemTemplate>
            </asp:TemplateField>

在 .cs 中

 protected void Rating1_Changed(object sender, EventArgs e)
{
    Rating ra= (Rating)sender; 
    GridViewRow gr=(GridViewRow) ra.Parent.Parent;          

    // table update required?

    Rating r = sender as Rating;
     int id = Convert.ToInt32(r.Tag);
     int lf = Convert.ToInt32(r.CurrentRating);
     string strSQL2 = "UPDATE [dbo].[wrms_config_m] set QueryId = " + lf + " where  Wrms_QueryId = " + id;
     ExecuteSQLUpdate(strSQL2);


}    

但我不知道如何将排序添加到评分列。通常我只会添加 SortExpression="####" 但这似乎不支持评级列。

我浏览了很多论坛,但找不到答案。任何帮助将不胜感激。

谢谢

4

1 回答 1

1

好的,我自己解决了这个问题。我将排序添加到错误的行。需要开启

<asp:TemplateField HeaderText="Favourites" SortExpression="num">
于 2012-11-29T14:50:58.900 回答