Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP General (http://www.velocityreviews.com/forums/f65-asp-general.html)
-   -   Thinking in the right way? (http://www.velocityreviews.com/forums/t794714-thinking-in-the-right-way.html)

Simon Harris 05-31-2004 06:16 PM

Thinking in the right way?
 
Hi All,

I'm new to ASP.Net.

As I understand it, the code and presentation should as much as possible
remain seperate. Code is in the 'codebehind' - Be it a script block at the
top of the page or seperate file. I have a situation where I need to list
the number of related records.

So far, I have a datalist, which displays records along with an indicator of
related records for that record, example... "France (4)" (Four related
records)

What I would like to do is display a messages depending on how many related
records are found
e.g. 'Record' where there is 1 record, and 'Records' where there are 1 or
more records, and 'No Records' where there are zero.

This would probably be quite straight forward in a script block at the point
of display, but I would like to do this the 'proper' way to keep my
presentation and logic seperate.

So...Can anyone advise how I would go about setting a label for each item in
my datalist? Is this done at the point of binding the data? Am I
understanding this correctly?

Heres what I currently have...

<ItemTemplate>
<a href="/show_resorts.aspx?countryid=<%# Container.DataItem("countryid")
%>">
<img src="/assets/images/flags/<%# Container.DataItem("countryid") %>.jpg"
title="View records for <%# Container.DataItem("country") %>"
class="SPDImage" /></br>
<%# Container.DataItem("country") %><br>
<span class="smallprint">(<%# Container.DataItem("Resorts") %>
Resorts)</span>
</a>
</ItemTemplate>

The above is a chunk from my datalist, which is bound to an MS Access
OleDbCommand.

Thanks!

Simon.

--
-
* Please reply to group for the benefit of all
* Found the answer to your own question? Post it!
* Get a useful reply to one of your posts?...post an answer to another one
* Search first, post later : http://www.google.co.uk/groups
* Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!



Evertjan. 05-31-2004 06:37 PM

Re: Thinking in the right way?
 
Simon Harris wrote on 31 mei 2004 in
microsoft.public.inetserver.asp.general:

> I'm new to ASP.Net.
>


In this NG we would al be new to that.

This is a classical ASP NG.

Plese see one of the [hearsay] dot.net groups.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

TomB 05-31-2004 06:41 PM

Re: Thinking in the right way?
 
http://www.aspfaq.com/etiquette.asp?id=5002

You should be able to call a code behind function.......

Function string ReturnPlural(int aNumber)
if aNumber=0 then
return "NoRecords"
elseif aNumber=1 then
return "1 Record"
else
return aNumber.ToString() & " Records"
end if
End Function

on your page you'd use...
<%=ReturnPlural(# Container.DataItem("Resorts") )#%>

*Note: I could be (and likely am) wrong, so try a dot net group..

Tom B


"Simon Harris" <toomuchspam@makesyoufat.com> wrote in message
news:uNhQXtzREHA.4020@TK2MSFTNGP11.phx.gbl...
> Hi All,
>
> I'm new to ASP.Net.
>
> As I understand it, the code and presentation should as much as possible
> remain seperate. Code is in the 'codebehind' - Be it a script block at the
> top of the page or seperate file. I have a situation where I need to list
> the number of related records.
>
> So far, I have a datalist, which displays records along with an indicator

of
> related records for that record, example... "France (4)" (Four related
> records)
>
> What I would like to do is display a messages depending on how many

related
> records are found
> e.g. 'Record' where there is 1 record, and 'Records' where there are 1 or
> more records, and 'No Records' where there are zero.
>
> This would probably be quite straight forward in a script block at the

point
> of display, but I would like to do this the 'proper' way to keep my
> presentation and logic seperate.
>
> So...Can anyone advise how I would go about setting a label for each item

in
> my datalist? Is this done at the point of binding the data? Am I
> understanding this correctly?
>
> Heres what I currently have...
>
> <ItemTemplate>
> <a href="/show_resorts.aspx?countryid=<%#

Container.DataItem("countryid")
> %>">
> <img src="/assets/images/flags/<%# Container.DataItem("countryid")

%>.jpg"
> title="View records for <%# Container.DataItem("country") %>"
> class="SPDImage" /></br>
> <%# Container.DataItem("country") %><br>
> <span class="smallprint">(<%# Container.DataItem("Resorts") %>
> Resorts)</span>
> </a>
> </ItemTemplate>
>
> The above is a chunk from my datalist, which is bound to an MS Access
> OleDbCommand.
>
> Thanks!
>
> Simon.
>
> --
> -
> * Please reply to group for the benefit of all
> * Found the answer to your own question? Post it!
> * Get a useful reply to one of your posts?...post an answer to another one
> * Search first, post later : http://www.google.co.uk/groups
> * Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!
>
>




Simon Harris 05-31-2004 07:03 PM

Re: Thinking in the right way?
 
Hi,

Sorry Guys n Gals - Wrong group, my wrong! :)

TomB - Good plan, I'll give it a crack anyways, whilst I wait for a reply
from the DotNet guys.

Simon.

"TomB" <shuckle@hotmailXXX.com> wrote in message
news:%23kmUS7zREHA.556@TK2MSFTNGP10.phx.gbl...
> http://www.aspfaq.com/etiquette.asp?id=5002
>
> You should be able to call a code behind function.......
>
> Function string ReturnPlural(int aNumber)
> if aNumber=0 then
> return "NoRecords"
> elseif aNumber=1 then
> return "1 Record"
> else
> return aNumber.ToString() & " Records"
> end if
> End Function
>
> on your page you'd use...
> <%=ReturnPlural(# Container.DataItem("Resorts") )#%>
>
> *Note: I could be (and likely am) wrong, so try a dot net group..
>
> Tom B
>
>
> "Simon Harris" <toomuchspam@makesyoufat.com> wrote in message
> news:uNhQXtzREHA.4020@TK2MSFTNGP11.phx.gbl...
> > Hi All,
> >
> > I'm new to ASP.Net.
> >
> > As I understand it, the code and presentation should as much as possible
> > remain seperate. Code is in the 'codebehind' - Be it a script block at

the
> > top of the page or seperate file. I have a situation where I need to

list
> > the number of related records.
> >
> > So far, I have a datalist, which displays records along with an

indicator
> of
> > related records for that record, example... "France (4)" (Four related
> > records)
> >
> > What I would like to do is display a messages depending on how many

> related
> > records are found
> > e.g. 'Record' where there is 1 record, and 'Records' where there are 1

or
> > more records, and 'No Records' where there are zero.
> >
> > This would probably be quite straight forward in a script block at the

> point
> > of display, but I would like to do this the 'proper' way to keep my
> > presentation and logic seperate.
> >
> > So...Can anyone advise how I would go about setting a label for each

item
> in
> > my datalist? Is this done at the point of binding the data? Am I
> > understanding this correctly?
> >
> > Heres what I currently have...
> >
> > <ItemTemplate>
> > <a href="/show_resorts.aspx?countryid=<%#

> Container.DataItem("countryid")
> > %>">
> > <img src="/assets/images/flags/<%# Container.DataItem("countryid")

> %>.jpg"
> > title="View records for <%# Container.DataItem("country") %>"
> > class="SPDImage" /></br>
> > <%# Container.DataItem("country") %><br>
> > <span class="smallprint">(<%# Container.DataItem("Resorts") %>
> > Resorts)</span>
> > </a>
> > </ItemTemplate>
> >
> > The above is a chunk from my datalist, which is bound to an MS Access
> > OleDbCommand.
> >
> > Thanks!
> >
> > Simon.
> >
> > --
> > -
> > * Please reply to group for the benefit of all
> > * Found the answer to your own question? Post it!
> > * Get a useful reply to one of your posts?...post an answer to another

one
> > * Search first, post later : http://www.google.co.uk/groups
> > * Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!
> >
> >

>
>




TomB 05-31-2004 07:17 PM

Re: Thinking in the right way?
 
I think the function should have been

Function ReturnPlural(aNumber as int) as String


"Simon Harris" <toomuchspam@makesyoufat.com> wrote in message
news:esGM7H0REHA.3944@TK2MSFTNGP11.phx.gbl...
> Hi,
>
> Sorry Guys n Gals - Wrong group, my wrong! :)
>
> TomB - Good plan, I'll give it a crack anyways, whilst I wait for a reply
> from the DotNet guys.
>
> Simon.
>
> "TomB" <shuckle@hotmailXXX.com> wrote in message
> news:%23kmUS7zREHA.556@TK2MSFTNGP10.phx.gbl...
> > http://www.aspfaq.com/etiquette.asp?id=5002
> >
> > You should be able to call a code behind function.......
> >
> > Function string ReturnPlural(int aNumber)
> > if aNumber=0 then
> > return "NoRecords"
> > elseif aNumber=1 then
> > return "1 Record"
> > else
> > return aNumber.ToString() & " Records"
> > end if
> > End Function
> >
> > on your page you'd use...
> > <%=ReturnPlural(# Container.DataItem("Resorts") )#%>
> >
> > *Note: I could be (and likely am) wrong, so try a dot net group..
> >
> > Tom B
> >
> >
> > "Simon Harris" <toomuchspam@makesyoufat.com> wrote in message
> > news:uNhQXtzREHA.4020@TK2MSFTNGP11.phx.gbl...
> > > Hi All,
> > >
> > > I'm new to ASP.Net.
> > >
> > > As I understand it, the code and presentation should as much as

possible
> > > remain seperate. Code is in the 'codebehind' - Be it a script block at

> the
> > > top of the page or seperate file. I have a situation where I need to

> list
> > > the number of related records.
> > >
> > > So far, I have a datalist, which displays records along with an

> indicator
> > of
> > > related records for that record, example... "France (4)" (Four

related
> > > records)
> > >
> > > What I would like to do is display a messages depending on how many

> > related
> > > records are found
> > > e.g. 'Record' where there is 1 record, and 'Records' where there are 1

> or
> > > more records, and 'No Records' where there are zero.
> > >
> > > This would probably be quite straight forward in a script block at the

> > point
> > > of display, but I would like to do this the 'proper' way to keep my
> > > presentation and logic seperate.
> > >
> > > So...Can anyone advise how I would go about setting a label for each

> item
> > in
> > > my datalist? Is this done at the point of binding the data? Am I
> > > understanding this correctly?
> > >
> > > Heres what I currently have...
> > >
> > > <ItemTemplate>
> > > <a href="/show_resorts.aspx?countryid=<%#

> > Container.DataItem("countryid")
> > > %>">
> > > <img src="/assets/images/flags/<%# Container.DataItem("countryid")

> > %>.jpg"
> > > title="View records for <%# Container.DataItem("country") %>"
> > > class="SPDImage" /></br>
> > > <%# Container.DataItem("country") %><br>
> > > <span class="smallprint">(<%# Container.DataItem("Resorts") %>
> > > Resorts)</span>
> > > </a>
> > > </ItemTemplate>
> > >
> > > The above is a chunk from my datalist, which is bound to an MS Access
> > > OleDbCommand.
> > >
> > > Thanks!
> > >
> > > Simon.
> > >
> > > --
> > > -
> > > * Please reply to group for the benefit of all
> > > * Found the answer to your own question? Post it!
> > > * Get a useful reply to one of your posts?...post an answer to another

> one
> > > * Search first, post later : http://www.google.co.uk/groups
> > > * Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!
> > >
> > >

> >
> >

>
>





All times are GMT. The time now is 11:48 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.