C# while loop not working with server side controls
<p>I have 5 records in my Database and the below code is working fine to retrieve all the 5 records and write them.</p>

<pre><code>while (dr.Read())
{
     String a1 = dr[0].ToString();
     Response.Write(a1);
}
</code></pre>

<p>but, when I remove <code>Resonse.Write(a1);</code> and using <code>repvals = a1;</code> the output is displaying only last one record but not all records.</p>

<pre><code>while (dr.Read())
{
    String a1 = dr[0].ToString();
    repvals = a1;
}
</code></pre>

<p>In the above code repvals is a server side HTML control declared &lt;%=repvals%> and declared as <code>protected string repvals</code> in code page.</p>
