472,782 Members | 3,524 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,782 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 7776
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.