473,322 Members | 1,911 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,322 software developers and data experts.

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 1437
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
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
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
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
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
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
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
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
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
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
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.