DataBinding the AJAX Control Toolkit's Rating Control

Posted by Nevada on Stack Overflow See other posts from Stack Overflow or by Nevada
Published on 2009-09-24T21:24:38Z Indexed on 2010/04/06 18:03 UTC
Read the original article Hit count: 409

I'm attempting to use the AJAX Control Toolkit's Rating control in a DataBinding scenario.

I have a ReuseRating column in my database that is a tinyint. It can hold values 1 through 5. Every record in the table has the value set to 1 currently.

If I do this in my ItemTemplate everything works fine. I get 1 star filled in on my rating control.

<act:Rating ID="ReuseRatingRating" runat="server"
  CurrentRating='<%# Convert.ToInt16(Eval("ReuseRating")) %>'
  MaxRating="5" 
  StarCssClass="ratingStar"
  WaitingStarCssClass="savedRatingStar"
  FilledStarCssClass="filledRatingStar"
  EmptyStarCssClass="emptyRatingStar" />

Now I want to DataBind this in my EditTemplate like so.

<act:Rating ID="ReuseRatingRating" runat="server"
  CurrentRating='<%# Convert.ToInt16(Bind("ReuseRating")) %>'
  MaxRating="5" 
  StarCssClass="ratingStar"
  WaitingStarCssClass="savedRatingStar"
  FilledStarCssClass="filledRatingStar"
  EmptyStarCssClass="emptyRatingStar" />

Note, that I changed my Eval to a Bind in the CurrentRating property. This throws the following error.

CS0103: The name 'Bind' does not exist in the current context

Can anyone help me out on this one? I've been knocking my head against the wall for a couple of hours now.

© Stack Overflow or respective owner

Related posts about ajaxcontroltoolkit

Related posts about databinding