An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
|
<
telerik:RadRotator ID="radRotateNews" runat="server"
Skin="Vista"
ScrollDuration="3000" FrameDuration="2000" RotatorType="FromCode"
Width="470px" Height="312px" CssClass="RadRotator_Default"
AppendDataBoundItems="true" >
</
telerik:RadRotator>
protected
void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dt = GetScreens();
radRotateNews.DataSource = dt;
CreateNewsScreens(dt);
radRotateNews.DataBind();
}
}
protected
void CreateScreens(DataTable dt)
{
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
string screenType = dt.Rows[i]["ScreenTypeDesc"].ToString();
RadRotatorItem newsScreen = new RadRotatorItem();
newsScreen.ItemTemplate =
new NewsRotatorTemplate(screenType, dt.Rows.Count);
radRotateNews.Items.Add(newsScreen);
}
}
else
{
//show a default screen/image
}
}
public
class NewsRotatorTemplate : ITemplate
{
private string templateType;
private int numberScreens;
public NewsRotatorTemplate(string screenType, int noScreens)
{
//
// TODO: Add constructor logic here
//
this.templateType = screenType;
this.numberScreens = noScreens;
}
public void InstantiateIn(Control container)
{
....
Label
lblScreenNo = new Label();
lblScreenNo.ID =
"lblScreenNo" + screenNo;
lblScreenNo.DataBinding +=
new EventHandler(lblScreenNo_DataBinding);
container.Controls.Add(lblScreenNo);
....
}
void
lblScreenNo_DataBinding(object sender, EventArgs e)
{
Label lblScreenNo = (Label)sender;
RadRotatorItem container = (RadRotatorItem)lblScreenNo.NamingContainer;
string fieldValue = DataBinder.Eval(container.DataItem, "ScreenNo").ToString();
lblScreenNo.Text = fieldValue;
}
[/code]
Any ideas?