ListItem li=new ListItem();
CheckBoxList tb = new CheckBoxList();
tb.ID="Answer";
for (int j = 0 ; j < dtSubQuestion.Rows.Count; j++)// 添加多选题答案
{
li=new ListItem();
li.Text=" ";
li.Value=(j+1).ToString();
tb.Items.Add(li);
}
v_Cell = new TableCell();
v_Cell.Controls .AddAt (0,tb);
v_Cell.HorizontalAlign=HorizontalAlign.Left;
v_Cell.BackColor=Color.White;
tR = new TableRow();
tR.Cells .AddAt (0,v_Cell);
iniTable.Rows.AddAt(iRowIndex,tR);
iRowIndex++;这个会报错
CheckBoxList tb = new CheckBoxList();
tb.ID="Answer";
for (int j = 0 ; j < dtSubQuestion.Rows.Count; j++)// 添加多选题答案
{
li=new ListItem();
li.Text=" ";
li.Value=(j+1).ToString();
tb.Items.Add(li);
}
v_Cell = new TableCell();
v_Cell.Controls .AddAt (0,tb);
v_Cell.HorizontalAlign=HorizontalAlign.Left;
v_Cell.BackColor=Color.White;
tR = new TableRow();
tR.Cells .AddAt (0,v_Cell);
iniTable.Rows.AddAt(iRowIndex,tR);
iRowIndex++;这个会报错
如果是table的话,看下面:你不能用这个方法。ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemWebUIWebControlsTableRowControlCollectionClassAddAtTopic.htmTable.RowControlCollection.AddAt Method [Visual Basic]See Also
Table.RowControlCollection Class | Table.RowControlCollection Members | System.Web.UI.WebControls Namespace
Language
C#C++JScriptVisual BasicShow All
This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.[Visual Basic]
Overrides Public Sub AddAt( _
ByVal index As Integer, _
ByVal child As Control _
)
[C#]
public override void AddAt(
int index,
Control child
);
[C++]
public: void AddAt(
int index,
Control* child
);
[JScript]
public override function AddAt(
index : int,
child : Control
);
See Also