This topic is locked

How can we use a field name for child link?

4/8/2004 11:59:16 PM
ASPRunnerPro General questions
Pete M author

I am trying to use a field name to replace the 'child' link test on a list page in AsprunnerPro, so that this acts like a custom-named hyperlink.
I'm not sure whether to cut some code from one part to another, or which of the two existing elements I should remove.
The field name is already on the list page.
Any suggestions? <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=515&image=1&table=forumtopics' class='bbc_emoticon' alt=':blink:' />

Sergey Kornilov admin 4/11/2004

Pete,
I'm not sure I understand what is 'child' link test. Please elaborate.

Pete M author 4/11/2004

OK
I have a Master List of Customers with a child table for Orders.
On the Customers_list page, I have fields for CustomerID, CustomerName and a link to 'Orders' (which I am calling the 'child link'), which opens a list of Orders for that customer.
What I would like to do is to have the CustomerName field used as the name for the link to the Orders table. So you would click on the Name to open the child table, rather than the 'Orders' link.
On another related subject, I was wondering if we could link to several child tables from the same Master list page?
For example, I have a Master table called 'Projects', which links to 'Contractors', 'Documents' and 'Photographs'. I wondered if I could link to these child tables from a single Master.

Sergey Kornilov admin 4/12/2004

Pete,
here is how you can do this. Take a look at the sample code from ASPRunnerPro live demo. This sample creates a master-detail link between Orders and Order Details tables.

sub loopRs(rsData,nPageSize)

...

<td align=center>

<% if IfNeedQuotes(rsData("OrderID").Type)="True" then strQuote="'" else strQuote="" end if %>

<a href="Order%20Details_list.asp" onClick = "document.forms.details.action='Order%20Details_list.asp';document.forms.details.masterkey.value='<%=EscapeQuotes(strQuote & rsData("OrderID") & strQuote)%>'; document.forms.details.submit();return false;">

Order Details

</a>

</td>


Replace child table name (in bold) with content of required column ( rsData.Fields("CustomerName") in your case ).
To create multiple master-details relationships use "Projects" table as a Master table for all child tables.
I hope this helps.

Pete M author 4/12/2004

Thanks Sergey
It worked after I pasted in the entire code from the CustomerName column, ie this:
<%

if IsBinaryField(rsData.Fields("CustomerName")) or Format("CustomerName")=FORMAT_DATABASE_FILE then

Response.Write CreateImageControl(rsData, "CustomerName", "")

else

Response.Write ProcessLargeText(GetData(rsData.Fields("CustomerName"), ""))

end if

%>

Replaced:
Order Details
Is that what you meant?
But then of course the customers name is not in the Master detail table at the top of the screen - unless this table is adjusted as well, which I will need to look into next.

Sergey Kornilov admin 4/12/2004

Pete,
I meant you can replace Order Details with <%=rsData.Fields("CustomerName")%>
To display customer name on the top of the page you can pass this name through hyperlink or form on the page and read it on the child page. Here is the complete example:

sub loopRs(rsData,nPageSize)

...

<td align=center>

<% if IfNeedQuotes(rsData("OrderID").Type)="True" then strQuote="'" else strQuote="" end if %>

<a href="Order%20Details_list.asp?customername=<%=rsData.Fields("CustomerName")%>" onClick = "document.forms.details.action='Order%20Details_list.asp';document.forms.details.masterkey.value='<%=EscapeQuotes(strQuote & rsData("OrderID") & strQuote)%>'; document.forms.details.submit();return false;">

<%=rsData.Fields("CustomerName")%>

</a>

</td>


After that on the child page you can use <%=Request.QueryString("CustomerName")%> to display customer name.
I hope this helps.