Accessing datatable from different methods
<p>I am creating a web application with back-end on ISeries.
In the page load I am populating a datatable and using it as a datasource for my gridview.</p>

<p>What is the best possible way to access the data in the datatable from other methods, on the same page? And in other pages?</p>

<p>The way I do currently is to get data from the gridview and populate in another datatable and then use it... Is there a better (elegant) way to do that? Is storing it in session a good idea??</p>

<pre><code>public partial class Main : System.Web.UI.Page
{
public DataTable dt;
protected void Page_Load(object sender, EventArgs e)
{
      loadData ld = new loadData();
      dt = ld.loadTable();
      GridView1.DataSource = dt;
      GridView1.DataBind();
}
protected void btn_Click(object sender, EventArgs e)
{
    foreach (DataRow row in dt.Rows)
    {
        // do something
    }
}
}
</code></pre>
