I currently have a table with two rows. Each row contains a checkbox (except the first) contains a checkbox in one column, a label in the next, and a text area in the third column.
I'm currently having two problems, one is my "Add Row" button will only add one row (and if I click it again, it won't add an additional row). I commented out the ID field thinking that might be why it won't add another row (don't want two items sharing and ID), however, that was not the case.
The other thing I don't know how to do is make it so that this function will be automatically called as soon as I start typing into the textbox "mcOpt1". Ideally I want it so that it will add a row with textbox named "mcOpt2", which will again add another row as soon as that one has text / is not empty.
I'm quite new to these languages, so how can this be achieved, if at all?
The Table:
<asp:Table ID="mcOptTable" runat="server" CssClass="halfwide">
<asp:TableRow runat="server" ID="question">
<asp:TableCell runat="server"></asp:TableCell>
<asp:TableCell runat="server">Question:</asp:TableCell>
<asp:TableCell runat="server">
<asp:TextBox ID="mcQuestion" runat="server" TextMode="MultiLine"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server" ID="opt1">
<asp:TableCell runat="server">
<asp:CheckBox ID="mcOpt1IsCorrect" runat="server" CssClass="leftmargin10" />
</asp:TableCell>
<asp:TableCell runat="server">Option 1:</asp:TableCell>
<asp:TableCell runat="server">
<asp:TextBox ID="mcOpt1" runat="server" TextMode="MultiLine"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
The Button
<asp:Button ID="addRow" runat="server" Text="Add a Row" OnClick="addRow_Click" />
The C# Add Table Row Code
protected void addRow_Click(object sender, EventArgs e)
{
TableRow row = new TableRow();
TableCell optText = new TableCell();
TableCell tBox = new TableCell();
TableCell isCor = new TableCell();
optText.Text = "Option 2:";
tBox.Text = "text box here";
//tBox.ID = "opt2";
isCor.Text = "?";
//isCor.ID = "opt2IsCorrect";
row.Cells.Add(isCor);
row.Cells.Add(optText);
row.Cells.Add(tBox);
mcOptTable.Rows.Add(row);
}