% ' ' Filename: linksGrid.asp ' Generated with CodeCharge 2.0.5 ' ASP 2.0 & Templates.ccp build 11/30/2001 ' '------------------------------- ' linksGrid CustomIncludes begin %> <% ' linksGrid CustomIncludes end '------------------------------- '=============================== ' Save Page and File Name available into variables '------------------------------- sFileName = "linksGrid.asp" sTemplateFileName = "linksGrid.html" '=============================== '=============================== ' linksGrid PageSecurity begin ' linksGrid PageSecurity end '=============================== '=============================== ' linksGrid Open Event begin ' linksGrid Open Event end '=============================== '=============================== ' linksGrid OpenAnyPage Event begin ' linksGrid OpenAnyPage Event end '=============================== '=============================== 'Save the name of the form and type of action into the variables '------------------------------- sAction = GetParam("FormAction") sForm = GetParam("FormName") '=============================== ' linksGrid Show begin '=============================== ' Display page '------------------------------- ' Load HTML template for this page '------------------------------- LoadTemplate sAppPath & sTemplateFileName, "main" '------------------------------- ' Load HTML template of Header and Footer '------------------------------- '------------------------------- SetVar "FileName", sFileName '------------------------------- ' Step through each form '------------------------------- links_Show '------------------------------- ' Process page templates '------------------------------- Parse "main", False '------------------------------- ' Output the page to the browser '------------------------------- Response.write PrintVar("main") ' linksGrid Show end '------------------------------- ' Destroy all object variables '------------------------------- ' linksGrid Close Event begin ' linksGrid Close Event end cn.Close Set cn = Nothing UnloadTemplate '=============================== '=============================== ' Display Grid Form '------------------------------- Sub links_Show() '------------------------------- ' Initialize variables '------------------------------- Dim rs Dim sWhere : sWhere = "" Dim sOrder : sOrder = "" Dim sSQL : sSQL = "" Dim sFormTitle: sFormTitle = "links" Dim HasParam : HasParam = false Dim iSort : iSort = "" Dim iSorted : iSorted = "" Dim sDirection : sDirection = "" Dim sSortParams : sSortParams = "" Dim iRecordsPerPage : iRecordsPerPage = 1000 Dim iCounter : iCounter = 0 Dim iPage : iPage = 0 Dim bEof : bEof = False SetVar "TransitParams", "" SetVar "FormParams", "" '------------------------------- ' Build ORDER BY statement '------------------------------- sOrder = " order by l.add_date DESC" iSort = GetParam("Formlinks_Sorting") iSorted = GetParam("Formlinks_Sorted") sDirection = "" if IsEmpty(iSort) then SetVar "Form_Sorting", "" else if iSort = iSorted then SetVar "Form_Sorting", "" sDirection = " DESC" sSortParams = "Formlinks_Sorting=" & iSort & "&Formlinks_Sorted=" & iSort & "&" else SetVar "Form_Sorting", iSort sDirection = " ASC" sSortParams = "Formlinks_Sorting=" & iSort & "&Formlinks_Sorted=" & "&" end if if iSort = 1 then sOrder = " order by l.[name]" & sDirection if iSort = 2 then sOrder = " order by l.[add_date]" & sDirection end if '------------------------------- ' Build base SQL statement '------------------------------- sSQL = "select [l].[add_date] as l_add_date, " & _ "[l].[description] as l_description, " & _ "[l].[link_id] as l_link_id, " & _ "[l].[name] as l_name, " & _ "[l].[url] as l_url " & _ " from [links] l " '------------------------------- '------------------------------- ' links Open Event begin ' links Open Event end '------------------------------- '------------------------------- ' Assemble full SQL statement '------------------------------- sSQL = sSQL & sWhere & sOrder '------------------------------- SetVar "FormTitle", sFormTitle '------------------------------- ' Process the parameters for sorting '------------------------------- SetVar "SortParams", sSortParams '------------------------------- '------------------------------- ' Open the recordset '------------------------------- openStaticRS rs, sSQL '------------------------------- '------------------------------- ' Process empty recordset '------------------------------- if rs.eof then set rs = nothing SetVar "DListlinks", "" Parse "linksNoRecords", False SetVar "linksNavigator", "" Parse "Formlinks", False exit sub end if '------------------------------- '------------------------------- ' Initialize page counter and records per page '------------------------------- iRecordsPerPage = 1000 iCounter = 0 '------------------------------- '------------------------------- ' Process page scroller '------------------------------- iPage = GetParam("Formlinks_Page") if IsEmpty(iPage) then iPage = 1 else iPage = CLng(iPage) while not rs.eof and iCounter < (iPage-1)*iRecordsPerPage rs.movenext iCounter = iCounter + 1 wend iCounter = 0 '------------------------------- '------------------------------- ' Display grid based on recordset '------------------------------- while not rs.EOF and iCounter < iRecordsPerPage '------------------------------- ' Create field variables based on database fields '------------------------------- fldadd_date = GetValue(rs, "l_add_date") flddescription = GetValue(rs, "l_description") fldlink_id = GetValue(rs, "l_link_id") fldname_URLLink = GetValue(rs, "l_url") fldname = GetValue(rs, "l_name") '------------------------------- ' links Show begin '------------------------------- '------------------------------- ' links Show Event begin ' links Show Event end '------------------------------- '------------------------------- ' Replace Template fields with database values '------------------------------- SetVar "link_id", ToHTML(fldlink_id) SetVar "name", ToHTML(fldname) SetVar "name_URLLink", fldname_URLLink SetVar "description", ToHTML(flddescription) SetVar "add_date", ToHTML(fldadd_date) Parse "DListlinks", True '------------------------------- ' links Show end '------------------------------- '------------------------------- ' Move to the next record and increase record counter '------------------------------- rs.MoveNext iCounter = iCounter + 1 wend '------------------------------- '------------------------------- ' links Navigation begin '------------------------------- bEof = rs.eof if rs.eof and iPage = 1 then SetVar "linksNavigator", "" else if bEof then SetVar "linksNavigatorLastPage", "_" else SetVar "NextPage", (iPage + 1) end if if iPage = 1 then SetVar "linksNavigatorFirstPage", "_" else SetVar "PrevPage", (iPage - 1) end if SetVar "linksCurrentPage", iPage Parse "linksNavigator", False end if '------------------------------- ' links Navigation end '------------------------------- '------------------------------- ' Finish form processing '------------------------------- set rs = nothing SetVar "linksNoRecords", "" Parse "Formlinks", False '------------------------------- ' links Close Event begin ' links Close Event end '------------------------------- End Sub '=============================== %>