Wrox Programmer Forums
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 28th, 2004, 05:05 PM
Authorized User
Join Date: Jun 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default 'helper' function?

First, I am using an asp:DataList, which does not allow AutoGenerateColumns=”False”

dr = cmd.ExecuteReader()
lstActivePatients.DataSource = dr

I am returning four values from my sproc to my web page: (0) RegistrationID, (1) Registrant, (2) RegistrationDate, and (3) ConfirmationDate

In my sproc, if the ConfirmationDate IS NULL I set it equal to ‘incomplete’, so the value returned to my aspx page is either a date or ‘incomplete’

This is the code in my DataList: if Container.DataItem(3) is not null and is a date then I want the date to show as a link; if Container.DataItem(3) is null then I simply want to show the word incomplete as text.

<td><asp:Hyperlink id="lnkConfirmation" Text='<%# Container.DataItem(3) %>' NavigateUrl='<%# "PatReg_Confirmation2.aspx?id=" & Container.DataItem(0) %>' runat="server" /></td> </tr> </ItemTemplate>

Function ShowLink(val)
  If val = ‘incomplete’ Then
    ShowLink = "Incomplete"
    ShowLink = "<a href=’RegConfirmation.aspx?id=” & QUERYSTRING & “’>DATE</a>"
  End If
End Function

I don’t know how to set the QUERYSTRING = Container.DataItem(0) and DATE = Container.DataItem(3) in the Helper Function above.

Thanks in advance for any help,

Old June 29th, 2004, 08:12 AM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

This should do it:

<%# ShowLink(Container.DataItem(0), Container.DataItem(3)) %>

Function ShowLink(queryString, date)
  If date = ‘incomplete’ Then
    Return "Incomplete"
    Return String.Format("<a href=’RegConfirmation.aspx?id={0}’>{1}</a>", queryString, date)
  End If
End Function

Work smarter, not harder

Similar Threads
Thread Thread Starter Forum Replies Last Post
unistalling Browser Helper Object maricar C# 0 October 7th, 2008 08:53 PM
1 quest on view helper hiteshp Struts 0 January 28th, 2008 03:06 AM
Helper Methods & Wrapper Classes? crazy ASP.NET 2.0 Basics 0 February 9th, 2007 12:31 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.