1

I have added an Ajax rating control to my Gridview as below:

  <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>

and in .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);


}    

but I don't know how to add sorting to the rating column. Normally I would just add SortExpression="####" but this doesn't seem to be supported for the rating column.

I have looked through lots of forums and can't find an answer. any help would be gratefully received please.

thanks

2
  • 1
    I'm not familiar with this control, but if you want the grid to re-sort itself on the change, wouldn't you have to rebind the grid? And if the "current rating" is bound to "num", shouldn't "num" be the SortExpression for the BoundColumn? Commented Nov 6, 2012 at 20:30
  • thanks Ann L. You may be right regarding the rebind but as this is an Ajax control doesn't appear to be needed. The sort Expression and allow sorting properties just don't appear to be supported or make any difference to this control. Commented Nov 7, 2012 at 17:01

1 Answer 1

1

Ok, resolved this myself. I was adding the sort to the wrong line. needed to be on

<asp:TemplateField HeaderText="Favourites" SortExpression="num">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.