473,386 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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!
Jul 19 '05 #1
4 1342
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)
Jul 19 '05 #2
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" <to*********@makesyoufat.com> wrote in message
news:uN**************@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!

Jul 19 '05 #3
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" <sh*****@hotmailXXX.com> wrote in message
news:%2***************@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" <to*********@makesyoufat.com> wrote in message
news:uN**************@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!


Jul 19 '05 #4
I think the function should have been

Function ReturnPlural(aNumber as int) as String
"Simon Harris" <to*********@makesyoufat.com> wrote in message
news:es**************@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" <sh*****@hotmailXXX.com> wrote in message
news:%2***************@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" <to*********@makesyoufat.com> wrote in message
news:uN**************@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!



Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Pelle | last post by:
Hello all, I have to admit, that the idea that occurred to me recently is weird. It was somehow inspired by the huge response on the "delete operator" thread, but goes into a somewhat different...
18
by: deanbrown3d | last post by:
I mean, is this correct? try { Screen->Cursor = crHourglass; Do something bad return false; else return true; }
18
by: Adam Zimny | last post by:
This is fragment of code from Bruce Eckel's Thinking in c++ ( last 3 couts are mine to show what happened ). The question is: is Bruce Eckel wrong or g++ ( my version is 3.2.3 ) is buggy ? //:...
15
by: Jon Skeet | last post by:
I've been briefly musing on what is probably a pretty silly idea, but one which would no doubt benefit from being discussed and thoroughly shot down in flames rather than being allowed to fester in...
9
by: Alvin Bruney | last post by:
The more knowledgable I get about this .net world, the more questions I have. ..NET uses pass by reference for all objects....uhhh I mean pass by value. (Couldn't resist this jab) Consider a...
7
by: Homa | last post by:
Hi, I'm thinking what will happen if two users access a page at the same time. If there are any local variable in the page, will this cause concurrency problem? Simarily, if this page need to...
4
by: Simon Harris | last post by:
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...
4
by: gopal | last post by:
Hi, i am now reading thru the thinking in C++ and i have some doubts at section CONST REFERENCES as The use of const references in function arguments is especially important because your...
1
by: Nemisis | last post by:
hi guys, Currently converting an old classic asp system to a OOP asp.net application. We are building the new application using a 3 tier arcitecture and i was wondering about the following. ...
2
by: ChrisM | last post by:
I've got a medium sized project written in C# for .NET1.1 the project is live, but still under constant development. There seems to be a lot of new stuff in .NET2.0 that I'm missing out on, and now...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.