| Main ASP .NET Tutorial Index |
Scott Mitchell June 2006 Download the ASPNET_Data_Tutorial_3_CS.exe sample code. Contents of Tutorial 3 (Visual C#)
Introduction Step 5: Adding the Default Page for Each SectionThe tutorials in our site are broken down into
different categories – Basic Reporting, Filtering,
Custom Formatting, and so on – with a folder for
each category and the corresponding tutorials as
ASP.NET pages within that folder. Additionally, each
folder contains a Let's display an unordered list using a Repeater
again, but this time we'll display the title and
description of the tutorials. Since the markup and
code to accomplish this will need to be repeated for
each
Figure 13. Add a New Web User
Control to the SectionLevelTutorialListing.ascx <%@ Control Language="C#" AutoEventWireup="true" CodeFile="SectionLevelTutorialListing.ascx.cs" Inherits="UserControls_SectionLevelTutorialListing" %>
<asp:Repeater ID="TutorialList" runat="server" EnableViewState="False">
<HeaderTemplate><ul></HeaderTemplate>
<ItemTemplate>
<li><asp:HyperLink runat="server" NavigateUrl='<%# Eval("Url") %>' Text='<%# Eval("Title") %>'></asp:HyperLink>
- <%# Eval("Description") %></li>
</ItemTemplate>
<FooterTemplate></ul></FooterTemplate>
</asp:Repeater>
SectionLevelTutorialListing.ascx.cs using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class UserControls_SectionLevelTutorialListing : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
// If SiteMap.CurrentNode is not null,
// bind CurrentNode's ChildNodes to the GridView
if (SiteMap.CurrentNode != null)
{
TutorialList.DataSource = SiteMap.CurrentNode.ChildNodes;
TutorialList.DataBind();
}
}
}
In the previous Repeater example we bound the
Once this Repeater has been created, open the
Figure 14. The User Control has
Been Added to
Figure 15. The Basic Reporting Tutorials are Listed SummaryWith the site map defined and the master page
complete, we now have a consistent page layout and
navigation scheme for our data-related tutorials.
Regardless of how many pages we add to our site,
updating the site-wide page layout or site
navigation information is a quick and simple process
due to this information being centralized.
Specifically, the page layout information is defined
in the master page Having completed the Data Access Layer and Business Logic Layer and having a consistent page layout and site navigation defined, we're ready to begin exploring common reporting patterns. In the next three tutorials we'll look at basic reporting tasks – displaying data retrieved from the BLL in the GridView, DetailsView, and FormView controls. Happy Programming! Further ReadingFor more information on the topics discussed in this tutorial, refer to the following resources:
About the Author
Scott Mitchell, author of six ASP/ASP.NET books and founder of 4GuysFromRolla.com, has been working with Microsoft Web technologies since 1998. Scott works as an independent consultant, trainer, and writer, recently completing his latest book, Sams Teach Yourself ASP.NET 2.0 in 24 Hours. He can be reached at mitchell@4guysfromrolla.com or via his blog, which can be found at http://ScottOnWriting.NET. Special Thanks To...This tutorial series was reviewed by many helpful reviewers. Lead reviewers for this tutorial include Liz Shulok, Dennis Patterson, and Hilton Giesenow. Interested in reviewing my upcoming MSDN articles? If so, drop me a line at mitchell@4GuysFromRolla.com.
Go to top or next tutorial |
||||



