| 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
|
||||



