473,608 Members | 2,410 Online
Bytes | Software Development & Data Engineering Community
+ 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("PRODCO DE")) &
"</TH>"
else
Response.Write "<TD width=20>&nbsp</TD><TD class=lnk1><A class='red'
HREF=""javascri pt:menu(" & lngEntity & ");"">" & trim(rs("PRODCO DE")) &
"</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:LinkButto n .." 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 1447
got it working

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

cheers

Henry

"Henry Nelson" <em***@minsterl ogistics.com> wrote in message
news:c8******** **@news8.svr.po l.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("PRODCO DE")) &
"</TH>"
else
Response.Write "<TD width=20>&nbsp</TD><TD class=lnk1><A class='red'
HREF=""javascri pt:menu(" & lngEntity & ");"">" & trim(rs("PRODCO DE")) &
"</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:LinkButto n .." 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
2053
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 (non-.Net) if I wanted to fill a list it may look something like this: -------START CODE <%
1
3299
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 have added notes to their work. I can not get the OnItemDataBound event to fire for the repeater control. I have created a scaled-down version of what it is that I am trying to accomplish just to make it easier to read. This does not work either. ...
1
1934
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 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...
3
2845
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 creating elements on the fly dynamically. I have a control that needs to display 3 columns and n number of rows depending on number of records. Sounds simple. But each Row has a control with its own data source binding and value must be selected...
5
3580
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 that for server control component , code is running on the server side. But if I take as example a Label. I place on a webform an HTM label control and a WebForm label control, I could see that properties are different for
2
1913
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: e.g. CompanyName, c1, c2, c3, etc .. The current format of my repeater is: <table> <asp:Repeater ID="rptCompanies" Runat="server">
2
2166
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 understanding how to go about this properly. For instance, the db column "myVal" is defined as a double in the db. In my table I want to display the value of that number by 1000. I used the code below and it does the trick. However, for some rows...
1
3319
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. When my Default page loads I'd like to set SkinID for each of these controls.
2
1308
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 value of the drop-down list. However, I can't evaluate the drop-down list submission at Page_Load, because the repeater has not yet been databound or rendered, so effectively the drop-down list doesn't yet exist.
4
1280
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 selected in the accordion. in the Repeater I've a checkbox (one for eache repeated field) checked by default that I select/deselect triggering the method OnCheckedChanged which updates the record in the table connected to the repeater.
0
8067
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8010
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8501
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
6015
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5479
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4030
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2477
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1336
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.