Since,
List<string> d
is a global variable. Every variable defined in a class inheriting Web.UI.Page will be destroyed at the end of the Page-Lifecycle, hence it will be null in a Postback. You can store it in the Session or the ViewState.
Try like this:
List<string> d= new List<string>();
protected void Button1_Click1(object sender, EventArgs e)
{
d.Add(TextBox1.Text);
d.Add(TextBox2.Text);
d.Add(TextBox3.Text);
d.Add(TextBox4.Text);
ViewState["Value"] = d;
}
protected void Button2_Click(object sender, EventArgs e)
{
d.Add(TextBox5.Text);
d.Add(TextBox6.Text);
}
protected void Button3_Click1(object sender, EventArgs e)
{
List<string> str = ViewState["Value"] as List<string>;
foreach (string i in str)
{
Response.Write(i);
}
}
--Amit