Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   Selectively displayed HTML in ItemTemplate of repeater control (http://www.velocityreviews.com/forums/t775775-selectively-displayed-html-in-itemtemplate-of-repeater-control.html)

msielski@gmail.com 03-31-2005 06:23 AM

Selectively displayed HTML in ItemTemplate of repeater control
 
I apologize if I don't explain this clearly, or if the solution is an
obvious one. I have been using ASP classic for a few years, but only
recently started with ASP.net. I have been reading Stephen Walther's
ASP.NET Unleashed 2nd Ed with much success, but have not been able to
figure out this issue:

I have a repeater web control on my page. I want to have a block of
HTML code appear within certain rows based on the value of a field in
the corresponding row of data. A simple example would be a repeater
listing products that displays 'New' icons next to the new ones.

In old ASP I would have probably put an IF block right there with the
optional HTML inside it. This isn't allowed in ASP.net, and rightly so
I suppose since it mixes code and presentation.

I have been very impressed with ASP.net so far and I'm sure there's a
reasonable way to do this. I have been searching and reading with no
luck. Any suggestions?

Thanks,
Matt


msielski@gmail.com 03-31-2005 06:47 AM

Re: Selectively displayed HTML in ItemTemplate of repeater control
 
Sometimes spelling out the problem helps make more clear how to search
for its answer. Just after I posted, I found a solution in:

http://groups-beta.google.com/group/...5f0fdd1db4592d

Seems like this will work. Please let me know if this is not the best
way to do it. What concerns me is that it requires putting HTML in a
function in the code-behind file, which would seem to mix up code and
presentation. However, it's still cleaner than the

<% if ... %> html <% end if %>

I would have done previously.

-Matt



All times are GMT. The time now is 10:53 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.