Error with the event handlers of dynamic linkbutton
<p>I am retrieving data from database depending upon the texboxes input and storing in a datatable , after then from datatable im sending data into dynamic table and displaying table in a panel,in the table all the data of the first column are of linkbuttons, i wrote event handler for dynamic link buttons , but the event handler is not triggering, and i want to store the linkbutton text in a string in the event handler, but the event handler is not triggering.</p>

<p>Code:</p>

<pre><code>protected void Button1_Click(object sender, EventArgs e)
{
   // GridView1.
    DataTable dt = new DataTable();

    OleDbConnection con = new OleDbConnection(str);
    con.Open();
    OleDbCommand cmd = new OleDbCommand();
    cmd.Connection = con;
    cmd.CommandText = "select ID,title,desc from [SO] where ID='" + TextBox1.Text.ToString() + "'or title='" + TextBox2.Text.ToString() + "'";
    OleDbDataAdapter db = new OleDbDataAdapter(cmd);
    db.Fill(dt);
    Table tb = new Table();
    tb.BorderColor = Color.Black;
    tb.BorderWidth = 2;

    DataRow dr;
    for (int i = 0; i &lt; dt.Rows.Count; i++)
    {

        TableRow tr = new TableRow();
        tr.BorderColor = Color.Black;
        tr.BorderWidth = 2;
        tr.ID = "tr" + i;
        TableCell tc = new TableCell();
        tc.BorderColor = Color.Black;
        tc.BorderWidth = 2;
        tc.ID = "tc" + i;
        TableCell tc1 = new TableCell();
        tc1.BorderColor = Color.Black;
        tc1.BorderWidth = 2;
        tc1.ID = "tc1" + i;
        TableCell tc2 = new TableCell();
        tc2.BorderColor = Color.Black;
        tc2.BorderWidth = 2;
        tc2.ID = "tc2" + i;
        LinkButton t = new LinkButton();
        t.BorderColor = Color.Black;
        t.BorderWidth = 2;
        t.ID = "t" + i;
        t.Click += new EventHandler(t_edit);

        TextBox t1 = new TextBox();
        t1.BorderColor = Color.Black;
        t1.BorderWidth = 2;
        t1.ID = "t1" + i;
        TextBox t2 = new TextBox();
        t2.BorderColor = Color.Black;
        t2.BorderWidth = 2;
        t2.ID = "t2" + i;

        dr = dt.Rows[i];
        t.Text = Convert.ToString(dr["ID"]);
        t1.Text = Convert.ToString(dr["title"]);
        t2.Text = Convert.ToString(dr["desc"]);
        tc.Controls.Add(t);
        tc1.Controls.Add(t1);
        tc2.Controls.Add(t2);
        tr.Cells.Add(tc);
        tr.Cells.Add(tc1);
        tr.Cells.Add(tc2);
        tb.Rows.Add(tr);

    }
    Panel1.Controls.Add(tb);

}
protected void t_edit(object sender, EventArgs e)
{

}
</code></pre>

<hr>

<p>k but by using the sessions concept im retrieving the total table so that the linkbuttons are also retrieving , and i want to add the linkbttons on a button click , here the problem is the eventhandler is not assiging to the linkbutton, and im adding linkbuttons on button click,not on page load.</p>
