Posted on: 8/11/2014 7:07:59 PM | Views : 558

Hey,
I have some code in App_Code folder so it's accessible everywhere.
I need to use a DataTable in the like this as well, but when I try to add rows from the content page, I get Null Reference errors:
App_Code:
public DataTable dt; private void Page_Load() { dt.Columns.Add(Col1, typeof(string)); dt.Columns.Add(Col2, typeof(string)); dt.Columns.Add(Col3, typeof(string)); } Page:
dt.Rows.Add("val1", "val2", "val3"); dt.Rows.Add("val1", "val2", "val3"); dt.Rows.Add("val1", "val2", "val3"); dt.Rows.Add("val1", "val2", "val3"); dt.Rows.Add("val1", "val2", "val3"); If I change
public DataTable dt; in App_Code to
public DataTable dt = new DataTable; ...

Go to the complete details ...