Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 8th, 2004, 01:16 PM
Registered User
 
Join Date: Jun 2004
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multiple classes

I am trying to get it to display the time and get it to read an XML file using C#.
<% Page Language="C#" runat="server" debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Xml" %>

<script language=C# runat="server">
 void Page_Load()
{
time.Text=DateTime.ToString();
}
}
String xmlFilename = @"C:\Comp Learning Language\ASPNET\Ch02\artists.xml";
DataSet newDataSet = new DataSet();
newDataSet.ReadXml (xmlFilename);
DataGrid1.Datasource = newDataSet;
DataGrid1.DataBind();
}
</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <asp:Label runat="server" id="time"></asp:Label>
        <asp:Label runat="server" id="DataGrid1"></asp:Label>
    </form>
</body>
</html>


  #2 (permalink)  
Old June 8th, 2004, 01:21 PM
Registered User
 
Join Date: Jun 2004
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry for double post.

Am I doing anything wrong with the above code?

  #3 (permalink)  
Old June 8th, 2004, 01:28 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

How can you bind a dataset to a label?
  #4 (permalink)  
Old June 8th, 2004, 01:37 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

Assuming the DataGrid is a data grid, try setting:

DataGrid1.Datasource = newDataSet.Tables(0).DefaultView;

instead.

Brian
  #5 (permalink)  
Old June 8th, 2004, 02:10 PM
Registered User
 
Join Date: Jun 2004
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Planoie, since I posted the topic, I have fixed that error.

bmains, the error message that I get seems to have a problem is in red
{
time.Text=DateTime.ToString();
}
{<!--the error message I get has a problem with this. Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1519: Invalid token '{' in class, struct, or interface member declaration -->
String xmlFilename = @"C:\Comp Learning Language\ASPNET\Ch02\artists.xml";
DataSet newDataSet = new DataSet();
newDataSet.ReadXml (xmlFilename);
DataGrid1.Datasource = newDataSet;
DataGrid1.DataBind();
}
  #6 (permalink)  
Old June 8th, 2004, 03:26 PM
Friend of Wrox
Points: 3,489, Level: 24
Points: 3,489, Level: 24 Points: 3,489, Level: 24 Points: 3,489, Level: 24
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Central, NJ, USA.
Posts: 1,102
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I'd expect to see the error you are- as you are sticking this inline code out there without anything calling it... you end the Page_Load {} and then have a new set of braces.... without any sub associated.. I don;t think you can do that- but it's a guess.. I don't do inline coding.. I use code-behind pages.


Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
  #7 (permalink)  
Old June 8th, 2004, 03:29 PM
Registered User
 
Join Date: Jun 2004
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Someone from another forum told me the same thing but that did not help as I already stated void Page_Load() and fed me back an error.

  #8 (permalink)  
Old June 8th, 2004, 05:28 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

This is for Page_Load:

{
time.Text=DateTime.ToString();
}

But this doesn't appear to be with any event? What is this for? You need to state something like

private void DoTHis()
{
String xmlFilename = @"C:\Comp Learning Language\ASPNET\Ch02\artists.xml";
DataSet newDataSet = new DataSet();
newDataSet.ReadXml (xmlFilename);
DataGrid1.Datasource = newDataSet;
DataGrid1.DataBind();
}

I imagine that this is part of the page_Load? If so, remove the }..{ between the page load and this previous code.

Hope this helps,

Brian
  #9 (permalink)  
Old June 9th, 2004, 12:03 PM
Registered User
 
Join Date: Jun 2004
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Question answered.

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple CSS classes different way dk6607 CSS Cascading Style Sheets 3 December 6th, 2006 08:23 AM
C# classes working for multiple forms w/ reseting Nathan Fleming C# 2005 1 September 11th, 2006 04:45 PM
Importing Multiple files in Multiple tables Versi Suomi Access 6 June 1st, 2005 08:47 AM
Multiple ADO multiple user login Oracle9i jhay0721 Pro VB Databases 1 April 4th, 2005 11:23 AM



All times are GMT -4. The time now is 12:12 PM.


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