473,480 Members | 2,194 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help - Changing the output of a repeater depending on the data

Hi all

I'm very new to dotNet and just trying to get my head around the right way
to do the thing that I would normally do in asp.

In asp I would loop through a recordset and output all the html dynamically
for the layout I want. I have seen some examples of
using a repeater and they seem to be the thing to use when you don't want a
table of results, but I'm not sure how to change the
<ItemTemplate> depending on the contents of the data.

For example if I wish a list of html links and headings in asp I would do
the following:-
'--------------------------------------------------

Response.Write "<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1>"
while not rs.eof
lngParent = CLng(rs("PARENT"))
lngEntity = CLng(rs("ENTITY"))
Response.Write "<TR>"
'##When the data in "PARENT" is 0 I want to display some text else I want
to output a blank cell then a link.
if lngParent = 0 then
Response.Write "<TH ALIGN=LEFT COLSPAN=2>" & trim(rs("PRODCODE")) &
"</TH>"
else
Response.Write "<TD width=20>&nbsp</TD><TD class=lnk1><A class='red'
HREF=""javascript:menu(" & lngEntity & ");"">" & trim(rs("PRODCODE")) &
"</A></TD>"

end if
Response.Write "</TR>"
rs.movenext
wend
Response.Write "</TABLE>"

'--------------------------------------------------

The javascript function "menu" would set a hidden field and submit the form.
Could someone give me an example of a repeater
using an "<asp:LinkButton .." or another method that would give me the same
result of the above code.
Could anyone suggest some good tutorials for aspx/dotNet - the ones I've
found so far are:-

http://docs.learnasp.com/quickstart/...uickstart.aspx
and
http://aspnet.4guysfromrolla.com/
cheers

Henry


Jul 21 '05 #1
1 1440
got it working

<asp:placeholder runat="server"
Visible='<%#Container.DataItem("PARENT") = 0%>'>
Parent is equal to Zero!
</asp:placeholder>
<asp:placeholder runat="server"
Visible='<%#Container.DataItem("PARENT") <> 0%>'>
Parent is not equal to Zero
</asp:placeholder>

cheers

Henry

"Henry Nelson" <em***@minsterlogistics.com> wrote in message
news:c8**********@news8.svr.pol.co.uk...
Hi all

I'm very new to dotNet and just trying to get my head around the right way
to do the thing that I would normally do in asp.

In asp I would loop through a recordset and output all the html dynamically for the layout I want. I have seen some examples of
using a repeater and they seem to be the thing to use when you don't want a table of results, but I'm not sure how to change the
<ItemTemplate> depending on the contents of the data.

For example if I wish a list of html links and headings in asp I would do
the following:-
'--------------------------------------------------

Response.Write "<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1>"
while not rs.eof
lngParent = CLng(rs("PARENT"))
lngEntity = CLng(rs("ENTITY"))
Response.Write "<TR>"
'##When the data in "PARENT" is 0 I want to display some text else I want
to output a blank cell then a link.
if lngParent = 0 then
Response.Write "<TH ALIGN=LEFT COLSPAN=2>" & trim(rs("PRODCODE")) &
"</TH>"
else
Response.Write "<TD width=20>&nbsp</TD><TD class=lnk1><A class='red'
HREF=""javascript:menu(" & lngEntity & ");"">" & trim(rs("PRODCODE")) &
"</A></TD>"

end if
Response.Write "</TR>"
rs.movenext
wend
Response.Write "</TABLE>"

'--------------------------------------------------

The javascript function "menu" would set a hidden field and submit the form. Could someone give me an example of a repeater
using an "<asp:LinkButton .." or another method that would give me the same result of the above code.
Could anyone suggest some good tutorials for aspx/dotNet - the ones I've
found so far are:-

http://docs.learnasp.com/quickstart/...uickstart.aspx
and
http://aspnet.4guysfromrolla.com/
cheers

Henry

Jul 21 '05 #2

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

Similar topics

2
2036
by: Daniel | last post by:
I'm new to .Net and all of its abilities so I hope this makes sense. Basically I'm confused on when is the appropriate time to use web forms controls vs. regular HTML. For example in ASP...
1
3286
by: slaforge | last post by:
I am trying use a repeater to process through the results of a sql query and produce a table that may or may not have multiple rows per record in the query, depending upon whether the technicians...
1
1928
by: Henry Nelson | last post by:
Hi all I'm very new to dotNet and just trying to get my head around the right way to do the thing that I would normally do in asp. In asp I would loop through a recordset and output all the...
3
2830
by: WebMatrix | last post by:
I am struggling with implementing somewhat complicated UI web-control. I explored Repeater, but I am not sure if it's the best way to go. I am leaning towards writing my own custom control and...
5
3563
by: serge calderara | last post by:
Dear all, I am new in asp.net and prepare myself for exam I still have dificulties to understand the difference between server control and HTML control. Okey things whcih are clear are the fact...
2
1901
by: GD | last post by:
I'd like to use a Repeater to display data coming back from a cross-tab report. Because it's a cross-tab, I generally don't know how many columns are coming back. They do follow a certain format: ...
2
2157
by: Mike Cain | last post by:
Hi, The Repeater control seems like exactly what I want to output rows of data from my database. However I need to do some manipulation to the data prior to it being output and I'm not...
1
3309
by: V | last post by:
Hello! I made custom control with tables and labels in it. In my page I have several of these controls. Each one should have different color of tables etc. I have different SkinIDs for that....
2
1284
by: champ.supernova | last post by:
I have a repeater, which contains in its <HEADERTEMPLATEa drop-down list (set to autopostback). If the page is a postback, I want to modify the SQL of the repeater's datasource, DEPENDING ON the...
4
1270
by: Vittorix | last post by:
I riepilogate with corrections and updates: I've an Ajax Accordion that gets data from a database, in its content there is a Repeater that gets data from another table, depending which header is...
0
7054
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6918
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
7057
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,...
0
7102
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6756
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4495
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3008
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
199
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.