Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does findcontrol need unique id, when I have given it the row to scan
    primarykey
    data
    text
    <h1>The code</h1> <pre><code> public partial class Table_Traversing : System.Web.UI.Page { Table table1 = new Table(); Button button1 = new Button(); protected void Page_Load(object sender, EventArgs e) { for (int adding_rows = 0; adding_rows &lt; 4; adding_rows++) { TableRow table_row1 = new TableRow(); TableCell table_cell1 = new TableCell(); TableCell table_cell2 = new TableCell(); Label The_text = new Label(); CheckBox checkmate = new CheckBox(); The_text.Text = "This is the text :-)"; checkmate.ID = "checkmate"; table_cell2.Controls.Add(checkmate); table_cell1.Controls.Add(The_text); table_row1.Controls.AddAt(0, table_cell1); table_row1.Controls.AddAt(1, table_cell2); table1.Rows.Add(table_row1); } button1.Text = "click me to export the value"; form1.Controls.AddAt(0, table1); form1.Controls.AddAt(1, button1); button1.Click += new EventHandler(button1_Click); } void button1_Click(object sender, EventArgs e) { CheckBox check_or_not = new CheckBox(); for (int i = 0; i &lt; table1.Rows.Count; i++) { check_or_not = (CheckBox)table1.Rows[i].FindControl("checkmate"); Response.Write(check_or_not.Checked.ToString()); } } } </code></pre> <h2>The error</h2> <blockquote> <p>Multiple controls with the same ID 'checkmate' were found. FindControl requires that controls have unique IDs.</p> <p>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p> <p>Exception Details: System.Web.HttpException: Multiple controls with the same ID 'checkmate' were found. FindControl requires that controls have unique IDs.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload