Rating Control in Code-Behind

I was declaring the rating control in a code-behind page, as such:

Rating rating = new Rating();
cell.Controls.Add(rating);

Then below it, I was setting all the properties like you would any other control.  Well, that didn't work because I kept getting an error, with the targeted control ID from the ExtenderControlBase class.  I suspected that the problem was I didn't have a unique ID setup correctly, so I played around with that, and the correct solution I got to work without error was this:

Rating rating = new Rating();
rating.ID = "rating" + _extenderCount.ToString();
_extenderCount += 1;
cell.Controls.Add(rating);

_extenderCount is a local variable that gets killed at the end of the page lifecycle, just used to ensure the name is unique. 

Published Friday, March 09, 2007 7:37 AM by bmains
Filed under:

Comments

No Comments

The leading UI suite for ASP.NET - Telerik radControls
Outstanding performance. Full ASP.NET AJAX support. Nearly codeless development.