Hello,
Is there a way to make a dataset global to all my aspx 2.0 web forms?
Thanks,
Chuck 13 2725
Sure. Declare it in your Global.asax as a public static field. Then you can
refer to it from any page as Global.MyDataSet
Peter
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Charles A. Lackman" wrote:
Hello,
Is there a way to make a dataset global to all my aspx 2.0 web forms?
Thanks,
Chuck
Thanks,
For some reason is it not working for me.
This is the code:
<%@ Application Language="VB" %>
<script runat="server">
Public MyDataset As New Dataset
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
End Sub
I Cannot put Public Static as an error is shown that says it is not a part
of a declaration.
When I type Global. - MyDataset is not listed.
Thanks,
Chuck
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:FC**********************************@microsof t.com...
Sure. Declare it in your Global.asax as a public static field. Then you can
refer to it from any page as Global.MyDataSet
Peter
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Charles A. Lackman" wrote:
Hello,
Is there a way to make a dataset global to all my aspx 2.0 web forms?
Thanks,
Chuck
You could put it in Application State.
Application.Lock()
Application("MyDataSet") = MyDataSet
Application.Unlock()
--
I hope this helps,
Steve C. Orr
MCSD, MVP, CSM http://SteveOrr.net
"Charles A. Lackman" <Ch*****@CreateItSoftware.netwrote in message
news:eQ**************@TK2MSFTNGP04.phx.gbl...
Hello,
Is there a way to make a dataset global to all my aspx 2.0 web forms?
Thanks,
Chuck
Charles,
"static" is the C# modifier. in VB.NET, you want to use the equivalent
keyword, "Shared".
Peter
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Charles A. Lackman" wrote:
Thanks,
For some reason is it not working for me.
This is the code:
<%@ Application Language="VB" %>
<script runat="server">
Public MyDataset As New Dataset
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
End Sub
I Cannot put Public Static as an error is shown that says it is not a part
of a declaration.
When I type Global. - MyDataset is not listed.
Thanks,
Chuck
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:FC**********************************@microsof t.com...
Sure. Declare it in your Global.asax as a public static field. Then you can
refer to it from any page as Global.MyDataSet
Peter
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Charles A. Lackman" wrote:
Hello,
Is there a way to make a dataset global to all my aspx 2.0 web forms?
Thanks,
Chuck
Hello,
I am not sure why this isn't working
<%@ Application Language="VB" %>
<script runat="server">
Public Shared ATest as string
OR
Public Shared MyDataset as New Dataset
In Default.aspx in the Load_Event
Global. does not show ATest or MyDataset
could there be a setting that I am missing?
Thanks
Chuck
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:FC**********************************@microsof t.com...
Charles,
"static" is the C# modifier. in VB.NET, you want to use the equivalent
keyword, "Shared".
Peter
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Charles A. Lackman" wrote:
Thanks,
For some reason is it not working for me.
This is the code:
<%@ Application Language="VB" %>
<script runat="server">
Public MyDataset As New Dataset
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
End Sub
I Cannot put Public Static as an error is shown that says it is not a part
of a declaration.
When I type Global. - MyDataset is not listed.
Thanks,
Chuck
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:FC**********************************@microsof t.com...
Sure. Declare it in your Global.asax as a public static field. Then you
can
refer to it from any page as Global.MyDataSet
Peter
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Charles A. Lackman" wrote:
Hello,
Is there a way to make a dataset global to all my aspx 2.0 web forms?
Thanks,
Chuck
Hello,
This appears to let me see the dataset throughout my application, but when I
make changes to it, the changes to follow. IE
This is Page 1
Dim ARow as DataRow = Application("MyDataset").Tables(0).NewRow
ARow(0) = "Hello"
Application("MyDataset).Tables(0).Rows.Add(ARow)
This is Page 2
Datagrid1.DataSource = Application("MyDataset")
Datagrid1.Databind
Could I be loosing my data on the postback? Any Suggestions.
Page 2 shows an empty dataset without the row I added on page 1
Thanks,
Chuck
"Steve C. Orr [MVP, MCSD]" <St***@Orr.netwrote in message
news:Oa**************@TK2MSFTNGP02.phx.gbl...
You could put it in Application State.
Application.Lock()
Application("MyDataSet") = MyDataSet
Application.Unlock()
--
I hope this helps,
Steve C. Orr
MCSD, MVP, CSM http://SteveOrr.net
"Charles A. Lackman" <Ch*****@CreateItSoftware.netwrote in message
news:eQ**************@TK2MSFTNGP04.phx.gbl...
Hello,
Is there a way to make a dataset global to all my aspx 2.0 web forms?
Thanks,
Chuck
After you make changes to the DataSet you should put the new modified
version back into Application State using the same lines of code I already
gave you.
--
I hope this helps,
Steve C. Orr
MCSD, MVP, CSM http://SteveOrr.net
"Charles A. Lackman" <Ch*****@CreateItSoftware.netwrote in message
news:ug**************@TK2MSFTNGP02.phx.gbl...
Hello,
This appears to let me see the dataset throughout my application, but when
I
make changes to it, the changes to follow. IE
This is Page 1
Dim ARow as DataRow = Application("MyDataset").Tables(0).NewRow
ARow(0) = "Hello"
Application("MyDataset).Tables(0).Rows.Add(ARow)
This is Page 2
Datagrid1.DataSource = Application("MyDataset")
Datagrid1.Databind
Could I be loosing my data on the postback? Any Suggestions.
Page 2 shows an empty dataset without the row I added on page 1
Thanks,
Chuck
"Steve C. Orr [MVP, MCSD]" <St***@Orr.netwrote in message
news:Oa**************@TK2MSFTNGP02.phx.gbl...
You could put it in Application State.
Application.Lock()
Application("MyDataSet") = MyDataSet
Application.Unlock()
--
I hope this helps,
Steve C. Orr
MCSD, MVP, CSM http://SteveOrr.net
"Charles A. Lackman" <Ch*****@CreateItSoftware.netwrote in message
news:eQ**************@TK2MSFTNGP04.phx.gbl...
>Hello,
Is there a way to make a dataset global to all my aspx 2.0 web forms?
Thanks, Chuck
Hello,
Still not working:
Page 1
Dim ADataset as new Dataset
'Table Added here
Application.Lock
Application("MyDataset") = ADataset
Application.UnLock
Page 2
Dim ADataset As New Dataset
ADataset.Merge(Application("MyDataset"))
ARow = ADataset.Tables(0).NewRow
ARow(0) = "Hello"
ADataset.Tables(0).Rows.Add(ARow)
Application.Lock
Application("MyDataset") = ADataset
Application.UnLock
Page 3
Datagrid1.Datasource = Application("MyDataset")
Datagrid1.Databind
Am I doing something wrong, it's not working.
Chuck
"Steve C. Orr [MVP, MCSD]" <St***@Orr.netwrote in message
news:uc*************@TK2MSFTNGP03.phx.gbl...
After you make changes to the DataSet you should put the new modified
version back into Application State using the same lines of code I already
gave you.
--
I hope this helps,
Steve C. Orr
MCSD, MVP, CSM http://SteveOrr.net
"Charles A. Lackman" <Ch*****@CreateItSoftware.netwrote in message
news:ug**************@TK2MSFTNGP02.phx.gbl...
Hello,
This appears to let me see the dataset throughout my application, but when
I
make changes to it, the changes to follow. IE
This is Page 1
Dim ARow as DataRow = Application("MyDataset").Tables(0).NewRow
ARow(0) = "Hello"
Application("MyDataset).Tables(0).Rows.Add(ARow)
This is Page 2
Datagrid1.DataSource = Application("MyDataset")
Datagrid1.Databind
Could I be loosing my data on the postback? Any Suggestions.
Page 2 shows an empty dataset without the row I added on page 1
Thanks,
Chuck
"Steve C. Orr [MVP, MCSD]" <St***@Orr.netwrote in message
news:Oa**************@TK2MSFTNGP02.phx.gbl...
You could put it in Application State.
Application.Lock()
Application("MyDataSet") = MyDataSet
Application.Unlock()
--
I hope this helps,
Steve C. Orr
MCSD, MVP, CSM http://SteveOrr.net
"Charles A. Lackman" <Ch*****@CreateItSoftware.netwrote in message
news:eQ**************@TK2MSFTNGP04.phx.gbl...
>Hello,
Is there a way to make a dataset global to all my aspx 2.0 web forms?
Thanks, Chuck
The namespace of this sample is "shred":
' Global.asax
Imports System.Web.SessionState
Imports System.Data
Public Class Global_asax
Inherits System.Web.HttpApplication
Public Shared MyDataSet As DataSet = New DataSet
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim dt As DataTable = New DataTable
dt.Columns.Add("TEST")
Dim row As DataRow = dt.NewRow
row("TEST") = "JUST A TEST"
dt.Rows.Add(row)
MyDataSet.Tables.Add(dt)
End Sub
'Page:
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim ds As DataSet = Global.shred.Global_asax.MyDataSet
Response.Write(ds.Tables(0).Rows(0)("TEST"))
End Sub
End Class
--Peter
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Charles A. Lackman" wrote:
Hello,
I am not sure why this isn't working
<%@ Application Language="VB" %>
<script runat="server">
Public Shared ATest as string
OR
Public Shared MyDataset as New Dataset
In Default.aspx in the Load_Event
Global. does not show ATest or MyDataset
could there be a setting that I am missing?
Thanks
Chuck
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:FC**********************************@microsof t.com...
Charles,
"static" is the C# modifier. in VB.NET, you want to use the equivalent
keyword, "Shared".
Peter
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Charles A. Lackman" wrote:
Thanks,
For some reason is it not working for me.
This is the code:
<%@ Application Language="VB" %>
<script runat="server">
Public MyDataset As New Dataset
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
End Sub
I Cannot put Public Static as an error is shown that says it is not a part
of a declaration.
When I type Global. - MyDataset is not listed.
Thanks,
Chuck
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:FC**********************************@microsof t.com...
Sure. Declare it in your Global.asax as a public static field. Then you
can
refer to it from any page as Global.MyDataSet
Peter
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Charles A. Lackman" wrote:
Hello,
>
Is there a way to make a dataset global to all my aspx 2.0 web forms?
>
Thanks,
Chuck
>
>
>
It worked Great!! Thank you VERY Much.
Chuck
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:2E**********************************@microsof t.com...
The namespace of this sample is "shred":
' Global.asax
Imports System.Web.SessionState
Imports System.Data
Public Class Global_asax
Inherits System.Web.HttpApplication
Public Shared MyDataSet As DataSet = New DataSet
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim dt As DataTable = New DataTable
dt.Columns.Add("TEST")
Dim row As DataRow = dt.NewRow
row("TEST") = "JUST A TEST"
dt.Rows.Add(row)
MyDataSet.Tables.Add(dt)
End Sub
'Page:
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim ds As DataSet = Global.shred.Global_asax.MyDataSet
Response.Write(ds.Tables(0).Rows(0)("TEST"))
End Sub
End Class
--Peter
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Charles A. Lackman" wrote:
Hello,
I am not sure why this isn't working
<%@ Application Language="VB" %>
<script runat="server">
Public Shared ATest as string
OR
Public Shared MyDataset as New Dataset
In Default.aspx in the Load_Event
Global. does not show ATest or MyDataset
could there be a setting that I am missing?
Thanks
Chuck
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:FC**********************************@microsof t.com...
Charles,
"static" is the C# modifier. in VB.NET, you want to use the equivalent
keyword, "Shared".
Peter
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Charles A. Lackman" wrote:
Thanks,
For some reason is it not working for me.
This is the code:
<%@ Application Language="VB" %>
<script runat="server">
Public MyDataset As New Dataset
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
End Sub
I Cannot put Public Static as an error is shown that says it is not a
part
of a declaration.
When I type Global. - MyDataset is not listed.
Thanks,
Chuck
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in
message
news:FC**********************************@microsof t.com...
Sure. Declare it in your Global.asax as a public static field. Then you
can
refer to it from any page as Global.MyDataSet
Peter
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Charles A. Lackman" wrote:
Hello,
>
Is there a way to make a dataset global to all my aspx 2.0 web forms?
>
Thanks,
Chuck
>
>
>
Declare it in a class in the APP_CODE folder with a public accessor.
But it does involve some code because your other pages will then
have to 'call it' from the class.
Testing...
Hello,
This appears to let me see the dataset throughout my application, but when I
make changes to it, the changes to follow. IE
This is Page 1
Dim ARow as DataRow = Application("MyDataset").Tables(0).NewRow
ARow(0) = "Hello"
Application("MyDataset).Tables(0).Rows.Add(ARow)
This is Page 2
Datagrid1.DataSource = Application("MyDataset")
Datagrid1.Databind
Could I be loosing my data on the postback? Any Suggestions.
Page 2 shows an empty dataset without the row I added on page 1
Thanks,
Chuck
"Steve C. Orr [MVP, MCSD]" <St***@Orr.netwrote in message
news:Oa**************@TK2MSFTNGP02.phx.gbl...
You could put it in Application State.
Application.Lock()
Application("MyDataSet") = MyDataSet
Application.Unlock()
--
I hope this helps,
Steve C. Orr
MCSD, MVP, CSM http://SteveOrr.net
"Charles A. Lackman" <Ch*****@CreateItSoftware.netwrote in message
news:eQ**************@TK2MSFTNGP04.phx.gbl...
Hello,
Is there a way to make a dataset global to all my aspx 2.0 web forms?
Thanks,
Chuck
<Testwrote in message news:et**************@TK2MSFTNGP04.phx.gbl...
Datagrid1.DataSource = Application("MyDataset")
Datagrid1.DataSource = (DataSet)Application("MyDataset") This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: James Morton |
last post by:
I am writing a c# windows forms application. I read in an XML file to a
dataset for read-only access (by the user and the application logic).
This is not an MDI app but has LOTS of seperate...
|
by: Mark Goldin |
last post by:
I have main aspx page with a number of user controls.
How can I create a global property that will be visible in every user
control?
Thanks
|
by: Mark Goldin |
last post by:
I'd like to have a dataset that will be declared on a main ASPX page and
visible in any custom or user control.
Is there a way of doing that?
Thanks
|
by: Vishwanathan Raman |
last post by:
Hi
I have a declared a static DataSet object SOBJ in Global.asax.I also have a
localy defined DataSet LSOBJ in Global.asax which I am storing in Application
State.Is there any technical...
|
by: Rick Hein |
last post by:
I've got a problem with an app I've been working on, the Caching object and
events not firing correctly. In a nutshell: When I'm debugging, and I set a
breakpoint in the removed item call back, the...
|
by: Mark Olbert |
last post by:
I have several ASP.NET 1.1 websites where I centralized a read-only dataset (i.e., one which no web page ever changed) and its
associated SqlDataAdapters.
In 2.0 I noticed that the Global.asax...
|
by: kuhrty |
last post by:
I am using a window form and trying to get a dataset used in the form
globally but I am having an issue setting the property and setting it
locally to the class. When I try to call the dataset...
|
by: Hans Greif |
last post by:
Hallo,
hello, i try to implement a global dataset - singleton based.
On www.bakterienforum.de i found a singleton implementation:
sealed class SingletonCounter
{
public int Counter = 0;
|
by: David Colliver |
last post by:
Hi,
using c#, 1.1
I know that we are not supposed to use global variables etc. in c#
I am having a problem, but not sure how to resolve. I did have another post
here, but may have over...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |