Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 1.0
This is the forum to discuss the Wrox book Beginning ASP.NET 1.0 with C# by Chris Goode, John Kauffman, Christopher L. Miller, Neil Raybould, S. Srinivasa Sivakumar, Dave Sussman, Ollie Cornes, Rob Birdwell, Matt Butler, Gary Johnson, Ajoy Krishnamoorthy, Juan T. Llibre, Chris Ullman; ISBN: 9780764543708
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 26th, 2004, 04:48 AM
Authorized User
 
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using Application state

Created a dataview using dataset in application_start event of Global.asax.vb file. I'm using this dataview to populate a data grid in the page_load event of my aspx file. But no result is displayed while running the application. No error shown.

What could be the reason? Can anyone throw some light....?

Thanks,
Apry

 
Old May 26th, 2004, 07:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Can you post your code?

Can you get anything asp.net to run on your machine?

 
Old May 26th, 2004, 07:31 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

DataView could have no rows. Are you catching errors, and if so, how are you catching errors?

Brian
 
Old May 26th, 2004, 11:06 PM
Authorized User
 
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
Here is my code written in Global.asax.vb file
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires when the application is started
        Dim ds1 As New DataSet()
        Dim FS As FileStream
        Dim Reader As StreamReader
        FS = New FileStream(Server.MapPath("XMLData.xml"), FileMode.Open, FileAccess.Read)
        Reader = New StreamReader(FS)
        ds1.ReadXml(Reader)
        FS.Close()
        Dim view As DataView
        view = New DataView(ds1.Tables(0))
        Application("Source") = view
    End Sub

In my aspx file
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'to use of application state to read a dataset in Application_Start
        Response.Write("Testing")
        Dim source As DataView
        source = Application("Source")
        MyDataGrid.DataSource = source
        MyDataGrid.DataBind()
    End Sub

Data is available in the XML file.

Thanks,
Apry

 
Old May 27th, 2004, 07:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

For testing, can you copy/paste the code into the Page_Load and see if it works from there any better?

Brian
 
Old May 27th, 2004, 11:33 PM
Authorized User
 
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Brian,
I tested it in the form load and it works fine.
I think the problem is assigning dataview (application_start) in the form load
source = Application("Source")

Apry

 
Old May 28th, 2004, 11:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

The source = Application("Source") shouldn't be a problem, as you can do this. To ensure you are working with a DataView, you can CType it to a DataView to make sure you are working with the correct type of object:

source = CType(Application("Source"), DataView)

To make sure you are getting rows back, in Application_Start, can you do:

Response.Write("Row Count: " & ds1.Tables(0).Rows.Count)
Response.Write("View Count: " & view.Count)

at the end, to make sure that the records are being brought back?

Thanks,

Brian
 
Old May 31st, 2004, 04:07 AM
Authorized User
 
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Brian,
Thanks for the help.
Surprisingly no result for the row count. Even the text is not displaying.
This means no action is triggering in the application_start event of global.asax.bv file

What could be the reason???

Apry






Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Application state variable value in Web form smp4774 ASP.NET 2.0 Basics 1 April 10th, 2007 07:55 AM
state management nalla ASP.NET 1.0 and 1.1 Professional 2 December 21st, 2005 01:19 AM
tradeoff application vs session state vs page Redden ASP.NET 1.x and 2.0 Application Design 1 October 6th, 2005 12:44 AM
Session State|View State|Do I have other options? rockon ASP.NET 1.x and 2.0 Application Design 2 October 5th, 2005 07:10 PM
IIS Application is unstable in the compiled state Dmitriy Pro VB 6 5 December 9th, 2003 09:51 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.