Impatient? Switch to another page!
Author: yuchen
For the remaining pages, we use the ASP + DataList or Repeater controls to draw a gourd Based on the samples. This is necessary because the data layout needs to be customized according to the design requirements, rather than a standard table display. There is a page named classcatalog. aspx, which requires you to check the value and then run one of the two possible outputs based on the selected value. This page uses the Repeater control. Therefore, we create rows and columns in the table explicitly without allowing the control to do everything. This is done within templates. In ASP, it looks like this:
Check for discounts
If rsSessions ("Special") = True Then
If this course offers discounts, "Special Offer!" is displayed !"
Response. Write "<td valign = top align = center>" & vbCrLf
Response. Write "<a href =" "classdetail. asp? SessionID ="
Response. Write rsSessions ("SessionID ")
Response. Write "name =" "Click for more detail" ">"
Response. Write "Special Offer! "
Response. Write "</td>"
Else
If this course does not offer discounts, output "--" in the bar "--"
Response. Write "<td valign = top align = center> -- </td>"
End If
To achieve the same effect in ASP +, we use a function. In the script block, which is located under the Page_Load event, we create the following code:
Function CheckSpecial (ByRef blnSpecial As Boolean ,_
ByRef intNumber As Integer) As String
If blnSpecial = True Then
CheckSpecial = "<a href =" & Chr (34 )&_
"Classdetail. aspx? SessionID = "&_
IntNumber & Chr (34) & "> Special !! </A>"
Else
CheckSpecial = "--"
End If
End Function
Then, you only need to call the function from ASP + Repeater:
<Template name = "ItemTemplate">
<Tr>
[Other data being displayed]
<Td valign = top align = center>
<% = CheckSpecial (Container. DataItem ("Special "),
Container. DataItem ("Session_ID") %>
</Td>
</Tr>
</Template>
Container refers to the parent object that involves the data of our ASP + Reapter control. Call Container. DataItem ("Special") and Container. DataItem ("Session_ID") to pass the values of columns in the parent object (namely the ASP + Repeater control) to the function.