|
 |
asp_databases thread: Passing DataFields Between Screens ?
Message #1 by "Ray Murphy" <raymondmurphy@c...> on Fri, 11 Aug 2000 8:55:51
|
|
The answer to this may be obvious, but here goes.
I've got part of an application which has three related ASP pages -
database being accessed is an SQL Server 7.0 database using ADO with ODBC.
The first page is a list of Projects (just ProjNo and ProjName) retrieved
from the 'projects' table, with the data formatted into an HTML table, with
ProjNo being used as a hyperlink <A HREF ...>.
Clicking on ProjNo takes you onto the second page showing the people
involved with that project (data retrieved from 'people' table), with the
data formatted into an HTML table showing ProjNo, PersonID, PersonSurname
-this time PersonID is used as the hyperlink.
Clicking on PersonID from this table takes you onto the third page which
should show full details (Address, JobTitle, TelNo etc) of the person
clicked from the second screen. If possible, I'd like to avoid another
access to the database on the third page as I've already retrieved the full
details for the person on the second page.
As the second screen only actually DISPLAYS PersonID and PersonSurname,
what is the best way of passing the additional details (Address, JobTitle,
TelNo) to the third page so that I can display them there ?
(Data is held on an SQL Server 7.0 database).
Thanks for any help on this.
Ray
Message #2 by "Nick Middleweek" <nickm@t...> on Fri, 11 Aug 2000 11:51:28 +0000
|
|
Ray
You can limit the columns that are retured in the SELECT statement so you
don't retrieve all of the data when you don't need it and then get that data
when you do. Use pass a comma seperated list of columns to return: SELECT
PersonID, Surname ..... Rather than SELECT *.
You could also continue doing what you doing and when you build the
hyperlink on the PersonID in the HTML table include in the link the rest of
other details so <A HREF="/personpage.asp?ID
Person100245&Surname=Middleweek&FirstName=Nick&Address1=10+Some+Street&Addre
ss2=SomeTown&Address3=&County=SomeCounty&Country=England&Tel=0123456789">Per
son100245</A> - Get the idea? Then when that URL is clicked you get the
values passed using Server.QueryString("ID") and Server.QueryString("Tel"),
etc.
Another method could be to store all the details in hidden form elements
with a naming convention for these form elements so you know which ones
belong to which PersonID. Then without going back to the Web Server you can
use Client Side Scripting to Open a new window and the write HTML to that
window which would include the data you want to be displayed!
var newwin = window.open('','Contacts','width=400,height=300')
newwin.document.write("Hello")
This will open a new window with width 400 and height 300.
Then it will write the word Hello into it.
HTH
Regards
Nick Middleweek
----------
> The answer to this may be obvious, but here goes.
>
> I've got part of an application which has three related ASP pages -
> database being accessed is an SQL Server 7.0 database using ADO with ODBC.
>
> The first page is a list of Projects (just ProjNo and ProjName) retrieved
> from the 'projects' table, with the data formatted into an HTML table, with
> ProjNo being used as a hyperlink <A HREF ...>.
>
> Clicking on ProjNo takes you onto the second page showing the people
> involved with that project (data retrieved from 'people' table), with the
> data formatted into an HTML table showing ProjNo, PersonID, PersonSurname
> -this time PersonID is used as the hyperlink.
>
> Clicking on PersonID from this table takes you onto the third page which
> should show full details (Address, JobTitle, TelNo etc) of the person
> clicked from the second screen. If possible, I'd like to avoid another
> access to the database on the third page as I've already retrieved the full
> details for the person on the second page.
>
> As the second screen only actually DISPLAYS PersonID and PersonSurname,
> what is the best way of passing the additional details (Address, JobTitle,
> TelNo) to the third page so that I can display them there ?
>
Message #3 by "Ray Murphy" <raymondmurphy@c...> on Fri, 11 Aug 2000 16:28:6
|
|
Nick,
Thanks for the reply - my code was already doing a limited SELECT rather
than
SELECT *, but my main concern was avoiding another database access in the
third
page as I'd already retrieved the data in the second page. So your advice
on
including the other details in the hyperlink looks worth a try, as this
would save having to read from the database again.
Once again, thanks for the advice - much appreciated.
Ray Murphy
GOLDSEAL COMPUTER CONSULTANTS
www.goldsealdata.com
--------------
On 08/11/00, ""Nick Middleweek" <nickm@t...>" wrote:
> Ray
>
> You can limit the columns that are retured in the SELECT statement so you
> don't retrieve all of the data when you don't need it and then get that data
> when you do. Use pass a comma seperated list of columns to return: SELECT
> PersonID, Surname ..... Rather than SELECT *.
>
> You could also continue doing what you doing and when you build the
> hyperlink on the PersonID in the HTML table include in the link the rest of
> other details so <A HREF="/personpage.asp?ID
> Person100245&Surname=Middleweek&FirstName=Nick&Address1=10+Some+Street&Addre
> ss2=SomeTown&Address3=&County=SomeCounty&Country=England&Tel=0123456789">Per
> son100245</A> - Get the idea? Then when that URL is clicked you get the
> values passed using Server.QueryString("ID") and Server.QueryString("Tel"),
> etc.
>
> Another method could be to store all the details in hidden form elements
> with a naming convention for these form elements so you know which ones
> belong to which PersonID. Then without going back to the Web Server you can
> use Client Side Scripting to Open a new window and the write HTML to that
> window which would include the data you want to be displayed!
>
> var newwin = window.open('','Contacts','width=400,height=300')
> newwin.document.write("Hello")
>
> This will open a new window with width 400 and height 300.
> Then it will write the word Hello into it.
>
>
> HTH
>
> Regards
> Nick Middleweek
>
>
> ----------
> > The answer to this may be obvious, but here goes.
> >
> > I've got part of an application which has three related ASP pages -
> > database being accessed is an SQL Server 7.0 database using ADO with ODBC.
> >
> > The first page is a list of Projects (just ProjNo and ProjName) retrieved
> > from the 'projects' table, with the data formatted into an HTML table, with
> > ProjNo being used as a hyperlink <A HREF ...>.
> >
> > Clicking on ProjNo takes you onto the second page showing the people
> > involved with that project (data retrieved from 'people' table), with the
> > data formatted into an HTML table showing ProjNo, PersonID, PersonSurname
> > -this time PersonID is used as the hyperlink.
> >
> > Clicking on PersonID from this table takes you onto the third page which
> > should show full details (Address, JobTitle, TelNo etc) of the person
> > clicked from the second screen. If possible, I'd like to avoid another
> > access to the database on the third page as I've already retrieved the full
> > details for the person on the second page.
> >
> > As the second screen only actually DISPLAYS PersonID and PersonSurname,
> > what is the best way of passing the additional details (Address, JobTitle,
> > TelNo) to the third page so that I can display them there ?
> >
|
|
 |