I have created link button dynamically and attach event to this. but when I invoke this event from page_load or page_init this works. but when i invoke this event from any simple button this is not working. could anybody help me. My code is following :-

protected void test2()
        Data Set d = new DataSet();
        LinkButton[] links = new LinkButton[5];
        d = test(); // function to create database and returning to it.
        int r = d.Tables["House_hold"].Rows.Count;
        for (int i = 0; i < r; i++)

            links[i].Text = d.Tables["House_hold"].Rows[i][6].ToString() + "<br /><br />";

            links[i].Click += new System.EventHandler(Lnkbut_Click);


protected DataSet fetchdata(string a)

        DataSet ds = new DataSet();

        if (con.State == ConnectionState.Open)

        string ConnectionString = "Data Source=COMPUTER6\\SQLEXPRESS;Initial Catalog=test_SRS;Integrated Security=True";

        con.ConnectionString = ConnectionString;
        String s = "SELECT * FROM HH_Member where HH_ID='" + a.Substring(0,2) + "'";
        SqlDataAdapter da = new SqlDataAdapter(s, con);
        da.Fill(ds, "HH_Member");
        return ds;



void Lnkbut_Click(object sender, EventArgs e)
        DataSet d2 = new DataSet();
        Label1.Text = "hello";

        LinkButton b = (LinkButton)sender;
        string s = b.ID;
        Label1.Text = s;
        GridView1.DataSource = d2.Tables["HH_Member"].DefaultView;


Your button needs to have 'causespostback' flagged to true. If you don't want the whole page to reload, you need to stick the results and button into an update panel.