Dynamically loading controls and postbacks
<p>On a dashboard page I'm loading several controls dynamically; the controls always need to be loaded so there is no <code>if (!Page.IsPostBack)</code> code.  The problem though is in that in the code-behind, we are using <code>Request.Form.GetValues</code> and a particular dropdown field's value is always null (presumably because the controls are being cleared and reloaded on a postback) and this is triggering an error later on in the page that expectes a value from this dropdown.  I have to use Request.Form.GetValues because the page enables dynamically adding rows (each row containing 5+ HTML inputs) via Javascript.</p>

<p>If I check for postback, then the button event of the control does not fire at all but instead the dashboard page is reloaded, and no controls are loaded at all (i.e. the page is blank).</p>

<p>How do I get around this issue?  I need to dynamically load the controls at all times, but I also need to retrieve the values via Request.Form.GetValues.  Any suggestions?</p>

<p><strong>EDIT</strong></p>

<p>Here's what the code looks like, roughly:</p>

<p>(Client-side HTML)</p>

<pre><code>&lt;table&gt;
    &lt;tr&gt;
        &lt;td align="center"&gt;
            &lt;select id="Class1" class="txtboxcomm" name="Class1" runat="server" /&gt;
            &lt;a href="javascript:classFinder('1')"&gt;&amp;nbsp;Look Up&lt;/a&gt;
        &lt;/td&gt;
   &lt;/tr&gt;    
&lt;/table&gt;
&lt;div id="action"&gt;
    &lt;asp:LinkButton ID="ibtnGetQuote" runat="server" OnClick="ibtnGetQuote_Click" CssClass="getQuote" AccessKey="G"&gt;Get Quote&lt;/asp:LinkButton&gt;
&lt;/div&gt;
</code></pre>

<p>(Server-side, in <code>ibtnGetQuote_Click</code> - this is actually a loop since user can append multiple rows; "i" is appended to the word "Class" to find the exact row)</p>

<pre><code>IList&lt;string&gt; classes = this.GetFormValues("Class1");

// This will return null all the time...
private IList&lt;string&gt; GetFormValues(string clientID)
{
    String[] values;
    values = Request.Form.GetValues(clientID);
    if (values == null)
    {
        Control ctl = FindControl(clientID); // uses built-in FindControl method
        values = Request.Form.GetValues(ctl.ClientID);
    }
    return values;
}
</code></pre>

<p>The original code was hardcoding the "ctl00$xx$xx" stuff, but the control may or may not be loaded so we cannot guarantee the name the control will get.  In fact, I'm not even sure if this will work for all scenarios since only the FIRST control is a server control, the rest are just standard HTML controls so wouldn't have a "ClientID".</p>
