473,325 Members | 2,442 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,325 software developers and data experts.

using a condition in a repeater control

Hi group,

Is it possible to use a condition in a repeater control ?
I 'd like to use a condition to create this <a
href='<%#DataBinder.Eval(Container.DataItem,"nieuw sid")%>.aspx'> part of
the repeater
At the moment I use "nieuwsid" to make the url but in some cases it has to
be <a href='wcharts.aspx'>

Is that possible ?
This is my full repeater code at the moment:

<asp:repeater id="NewsRepeater" runat="server">
<headertemplate>
<table style="WIDTH: 144px" cellSpacing="0" cols="1"
borderColorDark="gainsboro" cellPadding="0"
width="144" borderColorLight="whitesmoke" border="0">
<TR class="Hoofdpunten">
<asp:label id="LabelNieuws" CssClass="Hoofdpunten" runat="server"
Height="12">NIEUWS</asp:label></TR>
</headertemplate>
<itemtemplate>
<tr class="DatNieuws">
<%# DataBinder.Eval(Container.DataItem,"datum","{0:dd/MM/yyyy}")%>
</tr>
<tr class="Nieuws">
<img src=".\images\icon_news.gif" align="left"> <a
href='<%#DataBinder.Eval(Container.DataItem,"nieuw sid")%>.aspx'>
<%# DataBinder.Eval(Container.DataItem,"titel")%>
</a>
</tr>
</itemtemplate>
<footertemplate>
</table>
</footertemplate>
</asp:repeater>
thx in advance !
grz

Bernie V

--
http://www.djberniev.be
Nov 18 '05 #1
4 7796
Hi Bernie,

Instead of using an expression put an hyperlink object within the <tr>
tags and set his link(not the real name, but can't remember the right
one) property in the databound event of the repeater.

Hope this helps.

Stefano Mostarda MCP
Rome Italy.

Bernie V wrote:
Hi group,

Is it possible to use a condition in a repeater control ?
I 'd like to use a condition to create this <a
href='<%#DataBinder.Eval(Container.DataItem,"nieuw sid")%>.aspx'> part of
the repeater
At the moment I use "nieuwsid" to make the url but in some cases it has to
be <a href='wcharts.aspx'>

Is that possible ?
This is my full repeater code at the moment:

<asp:repeater id="NewsRepeater" runat="server">
<headertemplate>
<table style="WIDTH: 144px" cellSpacing="0" cols="1"
borderColorDark="gainsboro" cellPadding="0"
width="144" borderColorLight="whitesmoke" border="0">
<TR class="Hoofdpunten">
<asp:label id="LabelNieuws" CssClass="Hoofdpunten" runat="server"
Height="12">NIEUWS</asp:label></TR>
</headertemplate>
<itemtemplate>
<tr class="DatNieuws">
<%# DataBinder.Eval(Container.DataItem,"datum","{0:dd/MM/yyyy}")%>
</tr>
<tr class="Nieuws">
<img src=".\images\icon_news.gif" align="left"> <a
href='<%#DataBinder.Eval(Container.DataItem,"nieuw sid")%>.aspx'>
<%# DataBinder.Eval(Container.DataItem,"titel")%>
</a>
</tr>
</itemtemplate>
<footertemplate>
</table>
</footertemplate>
</asp:repeater>
thx in advance !
grz

Bernie V

Nov 18 '05 #2
SSW
Yes u can do it.

Replace Below
<img src=".\images\icon_news.gif" align="left"> <a
href='<%#DataBinder.Eval(Container.DataItem,"nieuw sid")%>.aspx'>
with
<img src=".\images\icon_news.gif" align="left"> <a
href='<%#(URConditions)?DataBinder.Eval(Container. DataItem,"nieuwsid"):DataB
inder.Eval(Container.DataItem,"wcharts.aspx")%>.as px'>
in ur aspx code
Please don't forget to replace URConditions with some condition which could
be evaluated.

I had tried below as sample and it works, So u can try on same line...

<asp:Repeater id="RP1" runat="server">
<ItemTemplate>
<%#DateTime.Now.Second>=30?DateTime.Now.ToString() :"NoDate"%><br>
</ItemTemplate>
<HeaderTemplate>
ABC<br>
</HeaderTemplate>
</asp:Repeater>

Yes I had also binded the RP1 in Code behind
DataTable dt = new DataTable("EX");
DataColumn dc = new DataColumn("Hello",
System.Type.GetType("System.String"));
dt.Columns.Add(dc);
DataRow dr = dt.NewRow();
dr["Hello"]="Hello";
dt.Rows.Add( dr );
RP1.DataSource = dt;
RP1.DataBind();

HTH...

Thanks,

sswalia
MCSD, MCAD, OCA
"Bernie V" <bernd.vantyghem@pandoradotbe> wrote in message
news:OB*************@TK2MSFTNGP11.phx.gbl...
Hi group,

Is it possible to use a condition in a repeater control ?
I 'd like to use a condition to create this <a
href='<%#DataBinder.Eval(Container.DataItem,"nieuw sid")%>.aspx'> part of
the repeater
At the moment I use "nieuwsid" to make the url but in some cases it has to
be <a href='wcharts.aspx'>

Is that possible ?
This is my full repeater code at the moment:

<asp:repeater id="NewsRepeater" runat="server">
<headertemplate>
<table style="WIDTH: 144px" cellSpacing="0" cols="1"
borderColorDark="gainsboro" cellPadding="0"
width="144" borderColorLight="whitesmoke" border="0">
<TR class="Hoofdpunten">
<asp:label id="LabelNieuws" CssClass="Hoofdpunten" runat="server"
Height="12">NIEUWS</asp:label></TR>
</headertemplate>
<itemtemplate>
<tr class="DatNieuws">
<%# DataBinder.Eval(Container.DataItem,"datum","{0:dd/MM/yyyy}")%>
</tr>
<tr class="Nieuws">
<img src=".\images\icon_news.gif" align="left"> <a
href='<%#DataBinder.Eval(Container.DataItem,"nieuw sid")%>.aspx'>
<%# DataBinder.Eval(Container.DataItem,"titel")%>
</a>
</tr>
</itemtemplate>
<footertemplate>
</table>
</footertemplate>
</asp:repeater>
thx in advance !
grz

Bernie V

--
http://www.djberniev.be

Nov 18 '05 #3
"SSW" <fr************@hotmail.com> schreef in bericht
news:ej**************@TK2MSFTNGP11.phx.gbl...
I had tried below as sample and it works, So u can try on same line...

<asp:Repeater id="RP1" runat="server">
<ItemTemplate>
<%#DateTime.Now.Second>=30?DateTime.Now.ToString() :"NoDate"%><br>
</ItemTemplate>
<HeaderTemplate>
ABC<br>
</HeaderTemplate>
</asp:Repeater>

Hi sswalia,
I used the method from above.
At the moment I have:

<itemtemplate>
<tr class="DatNieuws">
<%# DataBinder.Eval(Container.DataItem,"datum","{0:dd/MM/yyyy}")%>
</tr>
<tr class="Nieuws">
<img src=".\images\icon_news.gif" align="left"> <a
href='<%#(DataBinder.Eval(Container.DataItem,"type ")=="N")?DataBinder.Eval
(Container.DataItem,"nieuwsid"):"wcharts"%>.aspx'>
<%# DataBinder.Eval(Container.DataItem,"titel")%></a>
</tr>
</itemtemplate>
It works. But is this also possible to add another condition?
In C# it's something like that (I let the DataBinder things in the swith
statement in C# to compare with the ASP.NET things):

switch (DataBinder.Eval(Container.DataItem,"type"))
{
case "N": DataBinder.Eval(Container.DataItem,"nieuwsid").asp x;
break;
case "C":
wcharts.aspx;
break;
case "P":
javascript:if(window.open('./poll.aspx','nieuwvenster','width=300,height=250
,status=no,toobar=no,menubar=no,scrollbars=no')) ;
break;
default: DataBinder.Eval(Container.DataItem,"nieuwsid").asp x;
break;
}
Thanx in advance !!!!!!
grz

Bernie V


--
http://www.djberniev.be
Nov 18 '05 #4
"Bernie V" <bernd.vantyghem@pandoradotbe> schreef in bericht
news:uU**************@TK2MSFTNGP11.phx.gbl...
"SSW" <fr************@hotmail.com> schreef in bericht
news:ej**************@TK2MSFTNGP11.phx.gbl...


I found a solution.
This is how I did it:

<a
href="<%#(DataBinder.Eval(Container.DataItem,"type ").ToString()=="N")?DataBi
nder.Eval(Container.DataItem,"nieuwsid")+".aspx":( DataBinder.Eval(Container.
DataItem,"type").ToString()=="C")?"wcharts.aspx":" javascript:if(window.open(
'./poll.aspx','nieuwvenster','width=300,height=250,st atus=no,toobar=no,menub
ar=no,scrollbars=no'))"%>">

Thx to everyone !
grz

Bernie V
--
http://www.djberniev.be
Nov 18 '05 #5

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

Similar topics

3
by: Oleg | last post by:
I am using asp:repeater control. I would like to create a conditional row <tr> when the data in DataBinder.Eval(Container.DataItem, "Activity") returns '1'. I need something like this: <%if(...
0
by: Peter Johansen | last post by:
I have a question regarding the most effective way to implement key breaks in a repeater control. Consider the following data in a SQL table : Cat. | Products ----------------- Fruits |...
7
by: Jim | last post by:
I am trying to display images that are stored in a database, and I am using a repeater control. What I still use the Response.BinaryWrite method with a binding expression, if so, what with the...
1
by: olduncleamos | last post by:
Hello all, I am experimenting with the repeater control and ran into something that I wasn't expecting. I would appreciate if the experts can confirm or correct my understanding. Here is a...
4
by: Imran Aziz | last post by:
Hello All, I display a list of entries with a checkbox against them using a repeater control bound to a database table. Based on the value of database table I want to either show the checkbox for...
1
by: rhungund | last post by:
Hi all...i'm using the repeater control to display some records. The first record however needs to be displayed differently - it's shown as a featured item. The remainding records will be...
1
by: Ganesh Muthuvelu | last post by:
Hello, I am using a Repeater control to display data and also allow data editing. I simply have text boxes in my repeater template and allow the user to make changes as needed.. I also allow...
0
by: Christina | last post by:
I have a class variable that stores values in the following format: For Item1, Action1 = true Action2 = true Quantity = 10 For Item2, Action1 = true Action2 = FALSE
1
by: =?Utf-8?B?R3V1czEyMw==?= | last post by:
Hi, I just converted my asp.net app to vs2005 and now developing using vista and run into a problem using the repeater control. I bind the repeater control using If Not IsPostBack Then...
4
by: JFKJr | last post by:
Hello Guys, I have been trying to solve the following problem from past 3 days with no luck. This is what I am trying to do: I want to allow user (Professor) to choose a course material...
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...
1
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.