I have tried several different ways of rendering the control with the same
results. This was my first incantation.
private CheckBox ControlToRepeat(int index)
{
CheckBox control;
if(this.SurveyResponseType == ResponseType.CheckBox)
control = new CheckBox();
else
{
control = new RadioButton();
}
control.Page = this.Page;
control.ID = this.ClientID + "_" + index.ToString();
control.Attributes["value"] = this.Items[index].Value;
control.AutoPostBack = this.AutoPostBack;
control.TabIndex = this.TabIndex;
control.Enabled = this.Enabled;
return control;
}
protected override void Render(HtmlTextWriter output)
{
testLabel.Text = "Label";
testLabel.RenderControl(output);
RepeatInfo info = new RepeatInfo();
Style listStyle = base.ControlStyleCreated ? base.ControlStyle : null;
short tIndex = this.TabIndex;
Table t = new Table();
TableRow r1 = new TableRow();
TableRow r2 = new TableRow();
for(int i = 0; i<this.Items.Count; i++)
{
TableCell textCell = new TableCell();
textCell.Text = this.Items
.Text;
r1.Cells.Add(textCell);
TableCell valueCell = new TableCell();
valueCell.Controls.Add(ControlToRepeat(i));
r2.Cells.Add(valueCell);
}
t.Rows.Add(r1);
t.Rows.Add(r2);
t.RenderControl(output);
}
I have stuff in the LoadPostData method too, but it's irreleveant because
the method never gets called. I tried overriding the ControlCollection
and
adding them
my stuff that way and I've tried using the render methods for each of
these
objects and sending them directly to the HTMLTextWriter object.
Thanks for the help on this.
Teemu Keiski said:
Shouldn't be needed.
Can you show code for the control if it's not too long/complex to post?
How
does it render itself?
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke