I have an html table that I build dynamically. The table holds a couple of submit buttons and a list of items from a database with a checkbox before each of them. So the user is allowed to check as many items to be copied over to another table. I was trying to add another table row above what I just described simply to create headers for my html table. I have three columns and I would like the users to understand what they are looking at. But when I add the row I get a 'Specified argument was out of the range of valid values.Parameter name: index' and it highlights this line of code: if (ctrl.Controls[0].Controls[0] is CheckBox)So it looks like once I add that table row, it messes up my control numbering?below is a snippet of my code:
tblMain.BorderStyle =
tblMain.Width = 750;
tr =
{
txtVendor =
txtName =
txtVendor = item[
}
txtName = item[
contractorInfo =
alllist.Add(chk, contractorInfo);
chk.Text = txtName;
td1 =
td2 =
td3 =
tr.Cells.Add(td1);
tr.Cells.Add(td2);
tr.Cells.Add(td3);
td1.Controls.Add(chk);
td1.Font.Size = 8;
td2.Text = txtVendor;
td2.VerticalAlign =
td2.Font.Size = 8;
tblMain.Rows.Add(tr);
PlaceHolder1.Controls.Add(tblMain);
tblMain.Dispose();
btnCheckInContractor =
btnCheckInContractor.CausesValidation =
btnCheckInContractor.CssClass =
btnCheckInContractor.Text =
btnCheckInContractor.Click +=
PlaceHolder1.Controls.Add(btnCheckInContractor);