ASP 101 - Active Server Pages 101 photos.aspx
<%@ Page Language="VB" %>
<script language="VB" runat="server">
    Sub Page_Load(sender As Object, e As EventArgs)
		Dim mySortedList          As SortedList
		Dim intSelectedPhotoIndex As Integer
		Dim strPhotoId            As String
		Dim strPhotoTitle         As String
		mySortedList = New SortedList()
		mySortedList.Add ("09922491", "Freeway")
		mySortedList.Add ("09999118", "Symbology")
		mySortedList.Add ("10047069", "Ladies Night")
		mySortedList.Add ("19079112", "You Are So Fired")
		mySortedList.Add ("19124507", "A Charming Hangover")
		mySortedList.Add ("19151069", "Pay the Man")
		mySortedList.Add ("19297986", "Give Yourself A Hand")
		mySortedList.Add ("22474694", "Stack")
		mySortedList.Add ("22475208", "The Office")
		mySortedList.Add ("24231229", "aVoid")
		mySortedList.Add ("30423914", "Spring Into Action")
		mySortedList.Add ("31931795", "Home Improvement")
		strPhotoId = Request.QueryString("photo")
		If strPhotoID = "" Then
			PhotoDetailPanel.Visible = False
			PhotoDataList.DataSource = mySortedList
			PhotoDataList.DataBind
		Else
			intSelectedPhotoIndex = mySortedList.IndexOfKey(strPhotoId)
			strPhotoTitle = mySortedList.GetByIndex(intSelectedPhotoIndex)
			litPhotoTitle.Text = strPhotoTitle
			imgPhoto.ImageUrl      = "photos/" & strPhotoId & ".thw.jpg"
			imgPhoto.AlternateText = strPhotoTitle
			If intSelectedPhotoIndex = 0 Then
				linkPrev.Visible     = False
			Else
				linkPrev.Visible     = True
				linkPrev.NavigateUrl = "photos.aspx?photo=" _
					& mySortedList.GetKey(intSelectedPhotoIndex - 1)
			End If
			If intSelectedPhotoIndex = mySortedList.Count - 1 Then
				linkNext.Visible     = False
			Else
				linkNext.Visible     = True
				linkNext.NavigateUrl = "photos.aspx?photo=" _
					& mySortedList.GetKey(intSelectedPhotoIndex + 1)
			End If
			PhotoDetailPanel.Visible = True
		End If
    End Sub
</script>
<html>
<head>
<title>ASP.NET Photo Gallery Sample</title>
</head>
<body>
<form runat="server">
<h2>Photo Gallery</h2>
<asp:DataList id="PhotoDataList" runat="server"
	BorderWidth     = 1
	BorderColor     = "#000000"
	GridLines       = "Both"
	RepeatColumns   = 2
	RepeatDirection = "Horizontal"
>
    <ItemTemplate>
		<a href="photos.aspx?photo=<%# Container.DataItem.Key %>"
		><img src="photos/<%# Container.DataItem.Key %>.thm.jpg" border="0" /></a><br />
		<font size="-1"><%# Container.DataItem.Value %></font>
    </ItemTemplate>
</asp:DataList>
<asp:Panel id="PhotoDetailPanel" runat="server">
    <h3><asp:Literal id="litPhotoTitle" runat="server" /></h3>
	<p>
    <asp:Image id="imgPhoto" runat="server" />
	</p>
	<asp:HyperLink id="linkPrev" runat="server"
		Text = "<code><--</code> previous"
	/>
	   
	<asp:HyperLink id="linkNext" runat="server"
		Text = "next <code>--></code>"
	/>
    <p>
    <a href="photos.aspx">Back to the Main Photos Page</a>
    </p>	
</asp:Panel>
</form>
<p>
Thumbnails and photos from <a href="http://www.photos.com/">Photos.com</a>.
They have over 180,000 royalty-free stock photographs available by subscription.
</p>
<hr />
<p>
Click <a href="http://www.asp101.com/samples/photos_aspx.asp">here</a>
to read about and download the source code.
</p>
</body>
</html>