473,395 Members | 1,583 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

No display when previewed

tjc0ol
26
Hi guys,
I'm an .NET newbie, I need help.
Why is it that when I preview my aspx page it won't show up anything except this line:
<p>The data will be refreshed 10 seconds from now: <%= DateTime.Now %></p>

Here's my code below:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <%@ OutputCache Duration="10" VaryByParam="None" %>
  3. <%@ Import Namespace="System.Data.OleDb" %>
  4. <%@ Import Namespace="System.Data" %>
  5. <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
  6. <head runat="server">
  7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  8. <title>Page Data Caching</title>
  9. <script type="text/c#" language="C#" runat="server">
  10. DataView objDV;
  11. void Page_Load() {
  12.     if (IsPostBack) {
  13.         dgEmployees.DataSource = GetEmployees();
  14.         dgEmployees.DataBind();
  15.     }
  16. }
  17.  
  18. DataView GetEmployees() {
  19.     DataSet objDS = new DataSet();    
  20.     OleDbConnection objConn = new OleDbConnection(ConfigurationSettings.AppSettings["DNS"]);
  21.     OleDbDataAdapter objDA;
  22.  
  23.     objDV = (DataView)Cache["Employees"];
  24.     if (objDV == null) {
  25.         objDA = new OleDbDataAdapter("SELECT * FROM Employees", objConn);
  26.         objDA.Fill(objDS, "Employees");
  27.         objDV = objDS.Tables["Employees"].DefaultView;
  28.         Cache["Employees"] = objDV;
  29.     }
  30.  
  31.     return objDV;
  32. }
  33. void dgEmployees_Sort(Object s, DataGridSortCommandEventArgs e) {
  34.     objDV = GetEmployees();
  35.     objDV.Sort = e.SortExpression;
  36.     dgEmployees.DataSource = objDV;
  37.     dgEmployees.DataBind();
  38. }
  39. </script>
  40. </head>
  41. <body>
  42. <form runat="server">
  43. <asp:DataGrid ID="dgEmployees" runat="server" AutoGenerateColumns="false" GridLines="None" AllowSorting="true" OnSortCommand="dgEmployees_Sort">
  44.     <ItemStyle Font-Names="Arial" Font-Size="10pt" ForeColor="#000000" />
  45.     <HeaderStyle Font-Names="Arial" Font-Size="10pt" ForeColor="#FFFFFF" Font-Bold="true" BackColor="#003366" />
  46.     <AlternatingItemStyle Font-Names="Arial" Font-Size="10pt" BackColor="#CCCCCC" />
  47.     <Columns>
  48.         <asp:BoundColumn DataField="Name" HeaderText="Name" SortExpression="Name" />
  49.         <asp:BoundColumn DataField="Extension" HeaderText="Extension" SortExpression="Extension" />
  50.     </Columns>
  51.     </asp:DataGrid>
  52. <p>The data will be refreshed 10 seconds from now: <%= DateTime.Now %></p>
  53. </form>
  54. </body>
  55. </html>
thanks. -tj
Jul 22 '08 #1
10 1234
Plater
7,872 Expert 4TB
What version of asp.NET are you using? This looks like you are using VS2003 maybe?

And are you sure that this page is
A)Saved as an aspx page
and
B)Correctly deployed to the IIS server?
Jul 22 '08 #2
tjc0ol
26
What version of asp.NET are you using? This looks like you are using VS2003 maybe?

And are you sure that this page is
A)Saved as an aspx page
and
B)Correctly deployed to the IIS server?
Honestly I don't know how to check my asp.NET version, all I know is that I'm using Expression web on my aspx pages. My other aspx example pages runs smoothly but this example above doesn't.

Yes it was saved as an aspx page.

I think its in .NET Framework 1.1(version 1.1.4322.573) since I can't find any IIS server here. I can't find it in Administrative tools.

Here's my previous aspx example below that runs correctly:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <%@ OutputCache Duration="10" VaryByParam="None" %>
  3. <%@ Import Namespace="System.Data.OleDb" %>
  4. <%@ Import Namespace="System.Data" %>
  5. <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
  6. <head runat="server">
  7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  8. <title>Cached DataGrid</title>
  9. <script type="text/c#" language="C#" runat="server">
  10. OleDbConnection objConn = new OleDbConnection(ConfigurationSettings.AppSettings["DNS"]);
  11. OleDbDataAdapter objDA;
  12. DataSet objDS = new DataSet();
  13. void Page_Load() {
  14.     objDA = new OleDbDataAdapter("SELECT * FROM Employees", objConn);
  15.     objDA.Fill(objDS, "Employees");
  16.     dgEmployees.DataSource = objDS;
  17.     dgEmployees.DataBind();
  18. }
  19. </script>
  20. </head>
  21. <body>
  22. <form runat="server">
  23.     <asp:DataGrid ID="dgEmployees" runat="server" />
  24.     <p>The data will be refreshed 10 seconds from now: <%= DateTime.Now %></p>
  25. </form>
  26. </body>
  27. </html>
thanks. -tj
Jul 24 '08 #3
tjc0ol
26
What version of asp.NET are you using? This looks like you are using VS2003 maybe?

And are you sure that this page is
A)Saved as an aspx page
and
B)Correctly deployed to the IIS server?

Anyways I found it out my asp.NET version:
VersionCheck results for my machine:

Installed .NET Runtime(s)
OK.
Current version: The following runtimes are installed:
1.1.4322.2407 Version 1.1 Post-SP1 with KB928366 Apr 2007
2.0.50727.1433
3.0.4506.30 Version 3.0 RTM (RTM 4506.30) Nov 2006

ADO Database Runtime Version
OK.
Current version: 2.81.1132.0
Determined from file: C:\Program Files\Common Files\System\ado\msado15.dll

Internet Explorer Version
OK.
Current version: 7.0.6000.16674
Determined from file: C:\WINDOWS\system32\ieframe.dll

thanks. -tj
Jul 24 '08 #4
tjc0ol
26
What version of asp.NET are you using? This looks like you are using VS2003 maybe?

And are you sure that this page is
A)Saved as an aspx page
and
B)Correctly deployed to the IIS server?
Hi Again,
here's my ASP.NET version below:
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
Jul 24 '08 #5
DrBunchman
979 Expert 512MB
Are you sure that your DataGrid is being populated? If it isn't then the text in the <p> tags is the only other mark up on the page so would be the only thing that you'll see.

If you put a breakpoint on the line
Expand|Select|Wrap|Line Numbers
  1. dgEmployees.DataSource = GetEmployees();
and step through it, are you binding any data to the DataGrid?

Dr B
Jul 24 '08 #6
tjc0ol
26
Are you sure that your DataGrid is being populated? If it isn't then the text in the <p> tags is the only other mark up on the page so would be the only thing that you'll see.

If you put a breakpoint on the line
Expand|Select|Wrap|Line Numbers
  1. dgEmployees.DataSource = GetEmployees();
and step through it, are you binding any data to the DataGrid?

Dr B
Dr B,
I think yes, as according to my code I placed the
Expand|Select|Wrap|Line Numbers
  1. dgEmployees.DataSource = GetEmployees();
inside the
Expand|Select|Wrap|Line Numbers
  1. if(IsPostBack) {
There is a binding of data to the DataGrid inside the
Expand|Select|Wrap|Line Numbers
  1. DataView GetEmployees() {
  2.     DataSet objDS = new DataSet();    
  3.     OleDbConnection objConn = new OleDbConnection(ConfigurationSettings.AppSettings["DSN"]);
  4.     OleDbDataAdapter objDA;
  5.  
  6.     objDV = (DataView)Cache["Employees"];
  7.     if (objDV == null) {
  8.         objDA = new OleDbDataAdapter("SELECT * FROM Employees", objConn);
  9.         objDA.Fill(objDS, "Employees");
  10.         objDV = objDS.Tables["Employees"].DefaultView;
  11.     dgEmployees.DataSource = objDS;
  12.     dgEmployees.DataBind();
  13.  
  14.  
  15.         Cache["Employees"] = objDV;
  16.     }
  17.  
  18.     return objDV;
  19. }
  20.  
This code came from my asp.net book and I think there's a new version of this code since the version of it is ASP.NET and I'm using .NET 2 now. I hope this will be resolved. thanks. -tj
Jul 26 '08 #7
Plater
7,872 Expert 4TB
Do you have anything outside the:
Expand|Select|Wrap|Line Numbers
  1. if(isPostBack)
  2. {
  3. ...
  4. }
  5.  
Block?
Because nothing inside that block will be executed the first time the page loads.
You be wanting
Expand|Select|Wrap|Line Numbers
  1. if(!isPostBack)
  2. {
  3. ...
  4. }
  5.  
Jul 28 '08 #8
tjc0ol
26
Do you have anything outside the:
Expand|Select|Wrap|Line Numbers
  1. if(isPostBack)
  2. {
  3. ...
  4. }
  5.  
Block?
Because nothing inside that block will be executed the first time the page loads.
You be wanting
Expand|Select|Wrap|Line Numbers
  1. if(!isPostBack)
  2. {
  3. ...
  4. }
  5.  
There is a code inside the block
Expand|Select|Wrap|Line Numbers
  1. void Page_Load() {
  2.     if (IsPostBack) {
  3.         dgEmployees.DataSource = GetEmployees();
  4.         dgEmployees.DataBind();
  5.     }
  6. }
  7. DataView GetEmployees() {
  8.     DataSet objDS = new DataSet();    
  9.     OleDbConnection objConn = new OleDbConnection(ConfigurationSettings.AppSettings["DSN"]);
  10.     OleDbDataAdapter objDA;
  11.  
  12.     objDV = (DataView)Cache["Employees"];
  13.     if (objDV == null) {
  14.         objDA = new OleDbDataAdapter("SELECT * FROM Employees", objConn);
  15.         objDA.Fill(objDS, "Employees");
  16.         objDV = objDS.Tables["Employees"].DefaultView;
  17.     dgEmployees.DataSource = objDS;
  18.     dgEmployees.DataBind();
  19.  
  20.  
  21.         Cache["Employees"] = objDV;
  22.     }
  23.  
  24.     return objDV;
  25. }
Just as in the first post. Thanks, -tj
Jul 31 '08 #9
Plater
7,872 Expert 4TB
Ah ok, so you are never binding any data, so your page is blank.

Use this:
Expand|Select|Wrap|Line Numbers
  1. void Page_Load() {
  2.     if (!IsPostBack) {
  3.         dgEmployees.DataSource = GetEmployees();
  4.         dgEmployees.DataBind();
  5.     }
  6. }
  7.  
(Note: the ! before IsPostBack)
Jul 31 '08 #10
tjc0ol
26
Ah ok, so you are never binding any data, so your page is blank.

Use this:
Expand|Select|Wrap|Line Numbers
  1. void Page_Load() {
  2.     if (!IsPostBack) {
  3.         dgEmployees.DataSource = GetEmployees();
  4.         dgEmployees.DataBind();
  5.     }
  6. }
  7.  
(Note: the ! before IsPostBack)

thanks a lot this one solves the problem.
Aug 6 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Hemanth | last post by:
Hello there, I've a utility that runs on a linux machine. Basically, it opens a window, draws a figure and captures the image (screen) and stores it as a jpeg file. The utility requires a...
13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
2
by: Kay | last post by:
This function is used to display the context of a queue. I input an integer comparing with the queue cuisine number, if cuisine number is same as the input, it shows the context. However, it cannot...
18
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those...
1
by: John Phelan-Cummings | last post by:
When I add the name of a new individual in a, bound form, it will not display that person’s name in a label control of a second unbound form. I have a scheduling program that I am working on. ...
1
by: rbinington | last post by:
Hi, I am trying to write a DNN module that has the ability to insert articles into an article repository. I want the users to be able to move pages around and enter text into the FCKEditor. I...
5
by: libsfan01 | last post by:
function switch_display(switchme) { var el = document.getElementById(switchme); el.style.display = (el.style.display == 'none')? '' : 'none'; } im using this function to switch the display on...
9
by: tshad | last post by:
This was posted before but the message got messed up (all NLs were stripped out for some reason). I have 2 labels that hold the name of different images on my .aspx page. <asp:Label ID="Logo"...
9
by: Edward | last post by:
IE6 only displays certain text on my site if you mouse over it (!). I reduced the HTML down to this code below which still shows this effect/bug. My temporary solution was to take out all the...
0
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...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.