linkbuttons behaviour postbacks versus not postback
<p>Can you help me understand why, when the page is first loaded by the example below, the buttons don't work as intended eg Button 2 doesn't call  <code>GetItems(int.Parse("2"), 3);</code> but rather calls  <code>GetItems(int.Parse("4"), 3);</code> however after the first postback all the buttons work correctly e.g. Buttonx calls <code>GetItems(int.Parse("x"), 3);</code> 
Thanks</p>

<pre><code> protected void Page_Load(object sender, EventArgs e)
            {
                if(!IsPostBack)
                {
                    GetItems(1, 2); //default values (first time the page is loaded)

                }
                GenerateButtons(5);
            }

 private void GenerateButtons(int c)
        {
            LinkButton[] x = new LinkButton[c];

            for(int i=0; i&lt;c;i++)
            {
                x[i] = new LinkButton();
                x[i].Text = (i+1).ToString();
                Panel1.Controls.Add(x[i]);

                x[i].OnClick += new EventHandler(Button_Click);

            }
        }
protected void Button_Click(object sender, EventArgs e)
        {
            Button button = (Button)sender;  // Which button was clicked;

            GetItems(int.Parse(button.Text), 3); //3 is a constant; first argument is index of button extracted from its caption

        }
</code></pre>

<p>PS. when I refer to button 1 I have <code>button[0]</code> in mind. <code>button2=button[1]</code> and so on. after postback <code>button1</code> is correctly attached to the event to trigger <code>GetItems(1,3)</code>. Before the postback button1 causes <code>GetItems(3,3)</code> to run. Not as intended</p>