473,394 Members | 2,168 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,394 software developers and data experts.

Problem creating A to Z page

Hi all,
i'm struggling with a page idea I have.

I need to write a page with an A to Z list of available schools in the area.

I only want to display the letters in the A to Z which have school
information under them, i.e. A,b,c,d,f if no schools beginning with e are
available.

My chosen page layout out would be

A
+Name of School
+Name of School
B
+Name of School
-Name Of School
School Details
+Name of School
C
+Name Of School
E
+Name of School

I know I need to use Datalists for the drill down part of the page but I am
struggling with getting my list of schools displayed under the letters. Here
is what I've got so far:

Stored Procedure

ELECT DISTINCT(LEFT(SCH_NAME,1)) AS Letter

FROM db

ORDER BY Letter

SELECT DISTINCT(LEFT(SCH_NAME,1)) As Letter, SCH_DFEE, SCH_NAME

FROM db

SELECT SCH_DFEE, ADR_NUMBER, ADR_STREET, ADR_LOCALITY, ADR_TOWN, ADR_COUNTY,
ADR_POSTCODE, SCH_TEL, SCH_FAX, SCH_HEAD

FROM db


DataLayer.cs
public void SchoolsAtoZ(string conn_str)

{

SqlConnection conn = new SqlConnection(conn_str);

SqlDataAdapter daSchoolAtoZ = new SqlDataAdapter("EducationView_AtoZ",
conn);

dsEducation = new DataSet();

try

{

daSchoolAtoZ.SelectCommand.CommandType = CommandType.StoredProcedure;

daSchoolAtoZ.Fill(dsEducation);

dsEducation.Relations.Add("AtoZName",
dsEducation.Tables[0].Columns["Letter"],
dsEducation.Tables[1].Columns["Letter"]);

dsEducation.Relations.Add("NameAndDetails",
dsEducation.Tables[1].Columns["SCH_DFEE"],
dsEducation.Tables[2].Columns["SCH_DFEE"]);

}

catch (Exception ex)

{

throw ex;

}

finally

{

if (!(conn==null))

{

conn.Close();

}

}

}


A To Z Page (aspx)
<%@ Page language="c#" Codebehind="STSchoolsAtoZ.aspx.cs"
AutoEventWireup="false" Inherits="STEducationPages.STSchoolsAtoZ" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<HTML>

<HEAD>

<title>STSchoolsAtoZ</title>

<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">

<meta name="CODE_LANGUAGE" Content="C#">

<meta name="vs_defaultClientScript" content="JavaScript">

<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">

</HEAD>

<body>

<form id="Form1" method="post" runat="server">

<asp:DataList id="dlSchoolsAtoZ" runat="server"
RepeatDirection="Vertical" RepeatColumns="1" Width="100%"

CellPadding="0" CellSpacing="0" >

<HeaderTemplate>

Schools A To Z

</HeaderTemplate>

<ItemTemplate>

<table border="0" cellpadding="5" cellspacing="0" width="100%">

<tr>

<td valign="top">

<asp:Label ID="Letter" Runat="server" text='<%#
DataBinder.Eval(Container.DataItem, "Letter") %>' />

</td>

<td>

<asp:LinkButton ID="button1" Runat="server" CommandName="select">

<img src="images\webplus.gif" border="0" alt="Click plus to expand
details">

</asp:LinkButton>-->

<asp:Label ID="SCH_DFEE" Runat="server" text='<%#
DataBinder.Eval(Container.DataItem, "SCH_DFEE") %>' Visible="False" />

<asp:Label ID="SCH_NAME" Runat="server" text='<%#
DataBinder.Eval(Container.DataItem, "SCH_NAME") %>' />

</td>

</tr>

</table>

</ItemTemplate>

<SelectedItemTemplate>

<table border="0" cellpadding="2" cellspacing="0" width="100%">

<tr>

<td valign="top" width="100%" bgcolor="#66ffcc">

<asp:LinkButton ID="button2" Runat="server"
CommandName="showDetails">

<img src="images\webplus.gif" border="0" alt="Click plus to expand
details">

</asp:LinkButton>

<%# DataBinder.Eval(Container.DataItem, "SCH_NAME") %>

</td>

</tr>

<tr>

<td>

<table border="0" cellspacing="0" cellpadding="0">

<tr>

<td valign="top">

</td>

<td>

<asp:DataList ID="DetailsList" Runat="server" DataSource='<%#
GetChildRelation(Container.DataItem, "NameAndDetails") %>'
RepeatDirection="Vertical" RepeatColumns="1" Width="100%" CellPadding="0"
CellSpacing="0">

<HeaderTemplate>

<table border="0" cellpadding="0" cellspacing="0" width="100%">

<tr>

<td width="100">Line1</td>

<td width="200">Line2</td>

</tr>

</table>

</HeaderTemplate>

<SeparatorTemplate>

--------------------------------------------------------------------------------

</SeparatorTemplate>

<ItemTemplate>

<table border="0" cellpadding="0" cellspacing="0" width="100%">

<tr>

<td width="100">

<asp:Label ID="LABEL2" Runat="server" text='<%#
DataBinder.Eval(Container.DataItem, "ADR_NUMBER") %>' />

</td>

<td width="200">

<asp:Label ID="LABEL6" Runat="server" text='<%#
DataBinder.Eval(Container.DataItem, "ADR_STREET") %>' />

</td>

</tr>

</table>

</ItemTemplate>

</asp:DataList>

</td>

</tr>

</table>

</td>

</tr>

</table>

</SelectedItemTemplate>

</asp:DataList>

</form>

</body>

</HTML>


A to Z Page (Code Behind)
using System;

using System.Collections;

using System.ComponentModel;

using System.Configuration;

using System.Data;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

namespace STEducationPages

{

/// <summary>

/// Summary description for STSchoolsAtoZ.

/// </summary>

public class STSchoolsAtoZ : System.Web.UI.Page

{

protected System.Web.UI.WebControls.DataList dlSchoolsAtoZ;

private const string _DFEE = "DFEE";

private void Page_Load(object sender, System.EventArgs e)

{

// Put user code to initialize the page here

GetSchoolsData();

}

private void GetSchoolsData()

{

STEducationDataLayer.EducationDataLayer objLayer = new
STEducationDataLayer.EducationDataLayer();

objLayer.SchoolsAtoZ(ConfigurationSettings.AppSett ings["STEducation"]);

dlSchoolsAtoZ.DataSource = objLayer.dsEducation.Tables[0];

dlSchoolsAtoZ.DataBind();

}

protected void dlSchoolsAtoZ_ItemCommand(object Sender,
DataListCommandEventArgs e)

{

//Change the datalist to selected index

string cmd = ((LinkButton)e.CommandSource).CommandName;

if (cmd == "select")

((DataList)Sender).SelectedIndex = e.Item.ItemIndex;

GetSchoolsData();

ViewState[_DFEE] = ((Label)e.Item.FindControl("DFEE")).Text;

}

protected DataView GetChildRelation(object dataItem, string relation)

{

DataRowView drv = dataItem as DataRowView;

if (drv != null)

return drv.CreateChildView(relation);

else

return null;

}

#region Web Form Designer generated code

override protected void OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeComponent();

base.OnInit(e);

}

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

}

}


Hope this makes sense. Sorry about the post being so long.

Any help is appreciated.

Thanks

Andrew
Nov 19 '05 #1
0 1099

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Joan | last post by:
I am creating a word document from an asp page. I have no problems actaully creating the document and creating some tables that have data in them. I am using Response.ContentType =...
6
by: Robin Bonin | last post by:
In my user contol I am creating a set of dropdownlists. Each list is created based on input from the other lists. The problem I am having is setting the selected index on the lists. If someone...
3
by: Calvin Lai | last post by:
Hi all, I have a problem in creating web user control *programatically*. Problem as follows: 1. WebUserControl1 contains a server side table named Table1 2. WebForm1 contain a server panel...
2
by: umilmi81 | last post by:
I am having a problem creating an ASP.NET application in Visual Studio.NET 2003, installed on Windows XP Professional I get a message stating that I do not have ASP.NET 1.1 installed, so I can not...
14
by: Venkat Chellam | last post by:
I have a peculiar problem. I have a simple web application which loads some data from the oracle table and display in the datagrid in the webpage and datagrid has page enabled which shows 10 rows...
10
by: Curt_C [MVP] | last post by:
If I use it in my page it's fine but when I put it in a Class file for calling it returns the same # for each call. Any ideas why? I'm sure it's something I'll slap myself for but the only samples...
0
by: Chris | last post by:
Ok, I think this is an easy one - I've just been staring at it too long. I'm creating a datagrid in asp.net/c# from scratch, i.e. nothing at all in the aspx page. I'm also creating all the...
7
by: Nathan Sokalski | last post by:
I am having a problem saving an image with the same name it originally had. I have two similar versions of my code, one in which I close the FileStream used to open the original image before saving,...
8
by: Dhananjay | last post by:
hello everyone Do you have any information how to generate a tool using .net which is used to translate the web page contents to html format. Plz reply me asap Thanks in advance Dhananjay
8
by: Chizl | last post by:
I'm building a web server and having some issues with the TCPListener.Start(BackLog). It doesn't seem to do as expected. I'm using MS Web Stress Tool to test against my web server and when I...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.