i have table populated with data then i add checkbox and textbox into it. below is my code:
int count1 = 0;
TableCell tc;
foreach (TableRow tr in Resource_TBL.Rows)
{
tr.Cells.Add(tc = new TableCell());
CheckBox cbox = new CheckBox();
cbox.ID = ""+count1;
cbox.Attributes.Add("onclick", "document.getElementById('textbox_" + count1 + "').disabled=this.checked;");
tc.Controls.Add(cbox);
tr.Cells.Add(tc = new TableCell());
TextBox tbox = new TextBox();
tbox.ID = "textbox_" + count1;
tbox.CssClass = "form-control";
tbox.Enabled = false;
tbox.Attributes.Add("placeholder", "Enter Detail Here");
count1 += 1;
tc.Controls.Add(tbox);
}
i have tried :
cbox.Attributes.Add("onclick", "document.getElementById('textbox_" + count1 + "').Enabled=this.checked;");
but its not working. have an error saying(Unable to set property 'Enabled' of undefined or null reference)
is there any other way of doing it?