[英]asp.net c# gridview sorting by an AJAX rating control
我已經向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 =“ ####”,但似乎不支持評級列。
我瀏覽了很多論壇,但找不到答案。 任何幫助將不勝感激。
謝謝
好的,我自己解決了。 我將排序添加到錯誤的行。 需要繼續
<asp:TemplateField HeaderText="Favourites" SortExpression="num">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.