asp.net c#gridview按AJAX评级控件排序

时间:2012-11-06 18:00:53

标签: c# asp.net ajax gridview

我已经向我的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 =“####”但评级列似乎不支持此功能。

我查看过很多论坛,但找不到答案。我们将非常感激地收到任何帮助。

谢谢

1 个答案:

答案 0 :(得分:1)

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

<asp:TemplateField HeaderText="Favourites" SortExpression="num">