globle variable not accesed in functions

jmorge

New Member
hi,<BR><BR>I have decleared a globle variable as a datatable. I have modified it in a function. (I am not decleared it again in function. as I am using globle variable). But when I again calling it in another function I got error the datatable is null. I have tried to create the datatable in pageload but it is not working in that way also.<BR><BR>How to solve this problem.<BR><BR>TIA<BR><BR>Regards<BR>Rajkumar<BR><BR><BR>My aspx files goes like this<BR><html><BR><head><BR><script language="VB" runat="server"><BR>Dim objTable as DataTable<BR><BR>Sub Page_Load(Sender As Object, e As EventArgs)<BR> function1()<BR>end sub<BR><BR>sub function1()<BR> 'code to get values<BR> objTable = myDataset.Tables("values")<BR> 'code to display objTable. It is displaying here correctly<BR>End sub<BR><BR>sub function2(sender As Object, e As ImageClickEventArgs)<BR> 'code to work with objTable. It is giving error as objTable is null<BR>End sub<BR><BR></script><BR></head><BR><body><BR><asp:ImageButton id="id1" onclick="function2" runat="server" ImageUrl="image.gif" ></asp:ImageButton><BR></body><BR></html><BR>these functions are being called at different times, right?yes,<BR><BR>The function1 called when the pageis loaded.<BR>the function2 called when button is clicked.<BR><BR>rajkumarSub Page_Load(Sender As Object, e As EventArgs) <BR> function1() <BR>end sub <BR><BR>sub function1() <BR> 'code to get values <BR> objTable = myDataset.Tables("values") <BR> 'code to display objTable. It is displaying here correctly <BR>End sub <BR><BR>sub function2(sender As Object, e As ImageClickEventArgs) <BR> 'code to work with objTable. It is giving error as objTable is null <BR>End sub <BR><BR><BR><BR>when it posts back, it DOESN't call page_load()<BR><BR>therefore it doesn't call function1<BR><BR>http://www.readthe****ingmanual.co.uk/thanks Atrax,<BR><BR>I am calling the function in page_init(), and it is working fine now. Thanks again<BR><BR>rajkumarglad i could help. also worth pointing out I don't use ASP.NET - just a pure concept answer.... ;-)
 
Back
Top