2012-11-06 59 views
1

我加入了一個Ajax等級控制,以我的GridView如下:asp.net C#GridView的排序

<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

我不熟悉這個控制,但如果你想要網格重新排序自己的變化,你不會重新綁定網格?如果「當前評分」綁定到「num」,那麼不應該將「num」作爲BoundColumn的SortExpression? –

+0

謝謝安L.你可能是正確的重新綁定,但因爲這是一個Ajax控件似乎並不需要。排序表達式並允許排序屬性看起來不被支持或對此控件有任何不同。 – user1803963

回答

1

好的,自己解決了。我將這種錯誤添加到錯誤的行中。需要在

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