Wrox Programmer Forums
|
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 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 June 8th, 2004, 01:16 PM
Registered User
 
Join Date: Jun 2004
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>


 
Old June 8th, 2004, 01:21 PM
Registered User
 
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry for double post.

Am I doing anything wrong with the above code?

 
Old June 8th, 2004, 01:28 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

How can you bind a dataset to a label?
 
Old June 8th, 2004, 01:37 PM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old June 8th, 2004, 02:10 PM
Registered User
 
Join Date: Jun 2004
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();
}
 
Old June 8th, 2004, 03:26 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
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
 
Old June 8th, 2004, 03:29 PM
Registered User
 
Join Date: Jun 2004
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.

 
Old June 8th, 2004, 05:28 PM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old June 9th, 2004, 12:03 PM
Registered User
 
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Question answered.






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





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