Populate dynamic created controls with random number
<p>OK. Couple a days ago I asked a Question how to generate random numbers like 100, 1000, 10.000 etc without using arrays and my question got deleted because maybe the answer wasnt so obvious. I got that with simple solution, but now I have another problem. What I'm trying here is to populate every dynamic created Label with different random numbers. I dont know of what reason every 10 lines always get the same numbers. Here's the code behind that I'm trying to get work:</p>

<pre><code>protected void btnExample1Random_Click(object sender, EventArgs e)
{
    //Making the controls visible
    this.Master.FindControl("Div1").Visible = true;        

    //Generating the random numbers
    for (int i = 0; i &lt; 10; i++)
    {
        Label randomTask = new Label();
        Label emptyTask = new Label();
        TextBox userInputTextBox = new TextBox();
        Random rnd = new Random();

        int caseInt = rnd.Next(1, 4), myNum = 0;
        switch (caseInt)
        {
            case 1:
                caseInt = 100;
                myNum = rnd.Next(1, 100);
                break;
            case 2:
                caseInt = 1000;
                myNum = rnd.Next(1, 1000);
                break;
            case 3:
                caseInt = 10000;
                myNum = rnd.Next(1, 10000);
                break;
        }

        //Forming the controls
        randomTask.ID = "lbl" + i.ToString();
        randomTask.Text = caseInt.ToString() + " - " + myNum.ToString() + " ";
        userInputTextBox.ID = "box" + i.ToString();
        emptyTask.ID = "check" + i.ToString();

        //Adding the controls into the placeholder
        phTutorijal1.Controls.Add(randomTask);
        phTutorijal1.Controls.Add(userInputTextBox);
        phTutorijal1.Controls.Add(emptyTask);
        phTutorijal1.Controls.Add(new LiteralControl("&lt;br /&gt;"));
    }

    //Separating the next created controls into new line
    phTutorijal1.Controls.Add(new LiteralControl("&lt;br /&gt;"));
}
</code></pre>

<p>There's a bug in this code that I cant find it. Every 10 lines generated into the placeholder are with the same numbers. What did I miss here?</p>

<p><strong>Update:</strong> Michael Liu spotted where my bug is: I needed to put the <code>Random rnd = new Random();</code> outside the for cycle</p>
