0

Hi,

I have a web form. On it I am generating a gridview through a stored procedure. Now it has it's DataSource set to dataset object ds.

After generating this gridview. I want to generate an xls file. The code for that is correct. But since I am calling a separate function, dataset object does not exist there. So How to achieve a global daataset object. I tried declaring dataset obj at the top, but wont help !

Structure is somewhat like this:

partial class .....

Dim ds as DataSource = new Datasource()

sub for gridview()

gridview.datasource = ds

end sub

sub GetReport_Click () Handles GetReport.Click

[code for excel sheet]

[here i want to access same ds which has data that went in to gridview...but giving 'Object reference not set to instance of an onject' error]

end sub

End Class

Please help

P.s I tried putting DS object in session and retrieving it. That can be a solution. But what if I have hundreds of rows in my dataset? And if many users are there, wont memory consumption increase ? Can there be another more effiecient way ?

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by crishlay
0

Use Shared modifier to create an application scope object.

public class Test
   public shared ds as New DataSource
End Class

Edited by __avd: n/a

0

Hi,

I have a web form. On it I am generating a gridview through a stored procedure. Now it has it's DataSource set to dataset object ds.

After generating this gridview. I want to generate an xls file. The code for that is correct. But since I am calling a separate function, dataset object does not exist there. So How to achieve a global daataset object. I tried declaring dataset obj at the top, but wont help !

Structure is somewhat like this:

partial class .....

Dim ds as DataSource = new Datasource()

sub for gridview()

gridview.datasource = ds

end sub

sub GetReport_Click () Handles GetReport.Click

[code for excel sheet]

[here i want to access same ds which has data that went in to gridview...but giving 'Object reference not set to instance of an onject' error]

end sub

End Class

Please help

P.s I tried putting DS object in session and retrieving it. That can be a solution. But what if I have hundreds of rows in my dataset? And if many users are there, wont memory consumption increase ? Can there be another more effiecient way ?

http://forums.asp.net/t/1673067.aspx/1?How+to+make+global+dataset+object

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.