asp reapater

  • Thread starter Thread starter LIN
  • Start date Start date
L

LIN

i have an asp reapater and the code to display the repeater item looks like
this

<ItemTemplate>
<tr class="datagriditemstyle">
<td width="400"> <a href="<%# "http:\\" &
Server.UrlEncode(Container.DataItem("RefSiteName"))%>"><%#Container.DataItem
("RefsiteName")%></a> </td>
<td width="68"><%#Container.Dataitem("NoofRefers")%></td>
<td width="68"><%#Container.Dataitem("NoofRefers %")%>%</td>
</tr>
</ItemTemplate>

as u see my first row is a hyperlink row so all items displayed in tht row
are hyperlinked ..now when i have to check if the item in tht hyperlink row
is "others" then i shld not hyperlink it otherwise i shld for eg

my repeater will look like this

google 10 10%
yahoo 10 10%
others 80 80%

as per my code all the items in the sitename field will be linked but i dont
want others alone to be linked how can i do this
pls help me out

thanx
LIN
 
Instead of wrapping the whole data bound item with the a href tag, instead
pass the dataitem through a method, and within the method pass back the a
href if required

So

<a href="<%# "http:\\" &
Server.UrlEncode(Container.DataItem("RefSiteName"))%

becomes

(checkHREF(Container.DataItem("RefSiteName").ToString()))%

Where checkHREF is a method that accepts a string input and returns a string
formatted to href or not

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
 
Back
Top