my question is, if it is possible that the button_2 can call/use the data save in the datatable create in button_1. let say
void Button1_Click(Object sender, EventArgs e)
{
//some code to fill the datatable
}
now button 1 code has been done and it works, the only problem i have is i have no idea how to send de datatable from button_1 to button_2 this way button_2 can use the same data store in the datatable, by the way i am using C#, asp.net, and NOT using Visual Studio.
Since you state that the data is fetched in the event handler for
Button1and it should be available in the event handler fromButton2, you will have to persist the datatable in way so that it survives post backs.There are several possibilities:
Serializable, forDataTableit seems to work)Or, if the database operation to fetch the data is not “heavy” you could just load it from there when you need it.
For more reading regarding state management, see
http://msdn.microsoft.com/en-us/library/75x4ha6s.aspx
Edit: To give you a more specific recommendation. Try storing the
DataTablein the Session, like thisat the end of Button1_Click. Then get a reference to it using
in Button2_Click.