Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple controls with the same ID were found
    primarykey
    data
    text
    <p>I have following asp.net code but it gives error when I change dropdown selected index:</p> <pre><code>&lt;asp:UpdatePanel&gt; &lt;ContentTemplate&gt; &lt;asp:DropDownList ID="drp" runat="server" AutoPostBack="true" OnSelectedIndexChanged="drp_SelectedIndexChanged"&gt; &lt;asp:ListItem Text="ABC" Value="ABC"&gt;&lt;/asp:ListItem&gt; &lt;asp:ListItem Text="DEF" Value="DEF"&gt;&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; &lt;asp:Panel ID="pnl" runat="server"&gt; &lt;/asp:Panel&gt; &lt;asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" /&gt; &lt;/ContentTemplate&gt; &lt;Triggers&gt; &lt;asp:PostBackTrigger ControlID="drp" /&gt; &lt;asp:PostBackTrigger ControlID="Button1" /&gt; &lt;/Triggers&gt; &lt;/asp:UpdatePanel&gt; </code></pre> <p>Now made one function for create textbox and get textbox value into lable as following way</p> <pre><code>protected void drp_SelectedIndexChanged(object sender, EventArgs e) { if (drp.SelectedIndex != 0) { ViewState["controls"] = true; CreateTextbox(drp.SelectedIndex); } } private void CreateTextbox(int Number) { try { TextBox txtTextbox; Label lbltxtTextbox; for (int i = 0; i &lt; Number; i++) { txtTextbox = new TextBox(); txtTextbox.ID = "txtbox" + i; lbltxtTextbox = new Label(); lbltxtTextbox.ID = "lbltxtbox" + i; pnl.Controls.Add(txtTextbox); pnl.Controls.Add(lbltxtTextbox); } } catch (Exception ex) { } } private void GetTextboxvalue(int Number) { try { TextBox txtTextbox; Label lbltxtTextbox; for (int i = 0; i &lt; Number; i++) { txtTextbox = (TextBox)pnl.FindControl("txtbox" + i); lbltxtTextbox = (Label)pnl.FindControl("lbltxtbox" + i); lbltxtTextbox.Text = txtTextbox.Text; } } catch (Exception ex) { } } protected void Button1_Click(object sender, EventArgs e) { GetTextboxvalue(drp.SelectedIndex); } protected void Page_Load(object sender, EventArgs e) { if (ViewState["controls"] != null) if (drp.SelectedIndex != 0) { CreateTextbox(drp.SelectedIndex); } } </code></pre> <p>error is:</p> <pre><code>Multiple controls with the same ID 'txtbox0' were found. FindControl requires that controls have unique IDs. </code></pre>
    singulars
    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.
 

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