Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: Display String


Message #1 by Cindy.Somerville@h... on Wed, 14 Aug 2002 13:26:57
Hi
I'm a computer programming student, so all this stuff is new to me.
I?m using C sharp to develop a news board. 
The first page displays a list of news articles listed under the date that 
they were posted.  The second page shows the details of each story, 
listing all stories posted for the same day. I have everything working 
fine with no errors if I write each page of code on a separate page. 
I was using Response.Write to place the text on the screen. This worked 
very well.  But now I have to place my code into a project using ASP.NET 
Web Application and have it display inside a grid layout panel. I have no 
choice on the grid layout panel.  There will be ?window dressing? on all 
four sides of the page, so Response.Write will not work any more. 
I have looked at the Repeater control, but I don?t think it is going to 
work.  
What control do I use to place a string of HTML code inside the grid 
layout panel?

Thank you
Cindy 
 
Message #2 by "Hovik Melkomian" <melvik@b...> on Wed, 14 Aug 2002 19:29:14 +0430
Hi Cindy:
Im sure Repeter will show ur data & solve the problem!!!
But i dont know what u r going to show & where from!??!

Tell me more I'll do my best to help u.

Thats all foer now,
Hovik.
----- Original Message -----
From: <Cindy.Somerville@h...>
To: "aspx_beginners" <aspx_beginners@p...>
Sent: Wednesday, August 14, 2002 1:26 PM
Subject: [aspx_beginners] Display String


Hi
I'm a computer programming student, so all this stuff is new to me.
I'm using C sharp to develop a news board.
The first page displays a list of news articles listed under the date that
they were posted.  The second page shows the details of each story,
listing all stories posted for the same day. I have everything working
fine with no errors if I write each page of code on a separate page.
I was using Response.Write to place the text on the screen. This worked
very well.  But now I have to place my code into a project using ASP.NET
Web Application and have it display inside a grid layout panel. I have no
choice on the grid layout panel.  There will be 'window dressing' on all
four sides of the page, so Response.Write will not work any more.
I have looked at the Repeater control, but I don't think it is going to
work.
What control do I use to place a string of HTML code inside the grid
layout panel?

Thank you
Cindy



Message #3 by <cindy.somerville@h...> on Wed, 14 Aug 2002 11:29:53 -0400
In my data base i have fields, ID, Byline, Details, Date. I'm using 
OleDbDataReader to read and test the date. I need to list together all the 
bylines that have the same date.  
 Here is an example.


2002/07/05

	First byline here
	Second byline here
	Third byline here

2002/07/04

	First byline for this date
	Second

2002/06/25
	
	Byline here
	Another byline here


Can I have a display like this using Repeater?


Cindy Somerville 
Co-op Student


---------- Original Text ----------

From: "Hovik Melkomian" <melvik@b...>, on 2002-08-14 10:59 AM:

Hi Cindy:
Im sure Repeter will show ur data & solve the problem!!!
But i dont know what u r going to show & where from!??!

Tell me more I'll do my best to help u.

Thats all foer now,
Hovik.
----- Original Message -----
From: <Cindy.Somerville@h...>
To: "aspx_beginners" <aspx_beginners@p...>
Sent: Wednesday, August 14, 2002 1:26 PM
Subject: [aspx_beginners] Display String


Hi
I'm a computer programming student, so all this stuff is new to me.
I'm using C sharp to develop a news board.
The first page displays a list of news articles listed under the date that
they were posted.  The second page shows the details of each story,
listing all stories posted for the same day. I have everything working
fine with no errors if I write each page of code on a separate page.
I was using Response.Write to place the text on the screen. This worked
very well.  But now I have to place my code into a project using ASP.NET
Web Application and have it display inside a grid layout panel. I have no
choice on the grid layout panel.  There will be 'window dressing' on all
four sides of the page, so Response.Write will not work any more.
I have looked at the Repeater control, but I don't think it is going to
work.
What control do I use to place a string of HTML code inside the grid
layout panel?

Thank you
Cindy




---
Beginning ASP.NET 1.0 with C#
Entirely revised and updated for the final release, 
provides a step-by-step introduction with plenty of 
worked examples to help you to gain a deep understanding 
of what ASP.NET is all about, and how you can harness it 
to build powerful web applications. 
http://www.wrox.com/acon11.asp?ISBN=1861007345

Message #4 by "Hovik Melkomian" <melvik@b...> on Thu, 15 Aug 2002 10:19:59 +0430
OK Cindy:
Im going to send u a example of dataRepeater, I hope u can find out more.
Notice to Bold parts.
-----------------------------------------
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<Script Runat="Server">
  void Page_Load( Object s, EventArgs e )
  {
    SqlConnection myConnection;
    SqlCommand myCommand;
    myConnection = new SqlConnection( "Server=Localhost;uid=sa;Database=Pubs" );
    myCommand = new SqlCommand( "Select title, notes, type From Titles", myConnection );
    myConnection.Open();
    myRepeater.DataSource = myCommand.ExecuteReader();
    myRepeater.DataBind();
    myConnection.Close();
  }
</Script>

<html>
<head><title>Titles</title></head>
<body>
<form Runat="Server">

<asp:Repeater id="myRepeater" Runat="Server">
  <ItemTemplate>
  <%# DataBinder.Eval( Container.DataItem, "title" )%>
   <blockquote>
   <%# DataBinder.Eval( Container.DataItem, "notes" )%>
   </blockquote>
   <blockquote>
    <%# DataBinder.Eval( Container.DataItem, "type" )%>
   </blockquote>
 <hr>
  </Itemtemplate>
</asp:Repeater>

</form>
</body>
</html>
-----------------------------------------

Message #5 by <cindy.somerville@h...> on Thu, 15 Aug 2002 7:43:13 -0400
Thanks Hovik...

If I understand the example correctly it will display each item selected in 
the SQL statement on a seperate line on the screen.  
Is this correct?

My problem doesn't require the display of each item selected from the DB.

I'll try to explain it better using your example.

I would need to display, in groups, all titles and notes with the same type.

The display to the screen would show the type on the first line, then the 
second line would be the title and notes for the first record with a matching 
type.  Each record with a matching type would display the title and notes, on 
the following line.
***********************
type1
  titleA, notesA
  titleB, notesB

type2
  titleC, notesC
  tilteD, notesD
  tilteE, notesE

type3
  titleF, notesF
  tiltsG, notesG
  titleH, notesH

type4
  titleI, notesI
  titleJ, notesJ


************************

Here is the code that I am using now, it displays the data in the format 
required.
But now I need to provide more control over where on the screen it is to be 
displayed.
It needs to be displayed inside a grid layout panel.
Is there some way for me to simply write it inside the panel?
Or have I gone about this all wrong from the beginning?

*******************************************************************************
********************************
string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
strConnection += @"Data Source=C:\BegASPNET\News.mdb"; 
string mySelectQuery = "SELECT Date, Byline, ID FROM News WHERE Date >= 
#2002/05/05# ORDER BY Date DESC, ID;								
      
OleDbConnection myConnection = new OleDbConnection(strConnection);
OleDbCommand myCommand = new OleDbCommand(mySelectQuery,myConnection);
OleDbDataReader myReader = null;
	
DateTime testDate = Convert.ToDateTime("1960/11/04");
string strDataReaderStringResult = "";	

myConnection.Open();												
myReader = myCommand.ExecuteReader();	

while (myReader.Read()== true) 
  {
    if (testDate == myReader.GetDateTime(0))
  {
    strDataReaderStringResult += GetBylineString(myReader);			//function call
  }
    else
  {
    testDate = myReader.GetDateTime(0);
    strDataReaderStringResult += GetDateString(testDate);				//function call
    strDataReaderStringResult += GetBylineString(myReader);			//function call
  }

myReader.Close();													
myConnection.Close();
Response.Write(strDataReaderStringResult);
*******************************************************************************
***************************

			
Cindy 

---------- Original Text ----------

From: "Hovik Melkomian" <melvik@b...>, on 2002-08-15 1:49 AM:

OK Cindy:
Im going to send u a example of dataRepeater, I hope u can find out more.
Notice to Bold parts.
-----------------------------------------
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<Script Runat="Server">
  void Page_Load( Object s, EventArgs e )
  {
    SqlConnection myConnection;
    SqlCommand myCommand;
    myConnection = new SqlConnection( "Server=Localhost;uid=sa;Database=Pubs" 
);
    myCommand = new SqlCommand( "Select title, notes, type From Titles", 
myConnection );
    myConnection.Open();
    myRepeater.DataSource = myCommand.ExecuteReader();
    myRepeater.DataBind();
    myConnection.Close();
  }
</Script>

<html>
<head><title>Titles</title></head>
<body>
<form Runat="Server">

<asp:Repeater id="myRepeater" Runat="Server">
  <ItemTemplate>
  <%# DataBinder.Eval( Container.DataItem, "title" )%>
   <blockquote>
   <%# DataBinder.Eval( Container.DataItem, "notes" )%>
   </blockquote>
   <blockquote>
    <%# DataBinder.Eval( Container.DataItem, "type" )%>
   </blockquote>
 <hr>
  </Itemtemplate>
</asp:Repeater>

</form>
</body>
</html>
-----------------------------------------


---
Beginning ASP.NET 1.0 with C#
Entirely revised and updated for the final release, 
provides a step-by-step introduction with plenty of 
worked examples to help you to gain a deep understanding 
of what ASP.NET is all about, and how you can harness it 
to build powerful web applications. 
http://www.wrox.com/acon11.asp?ISBN=1861007345


  Return to Index