Selectively displayed HTML in ItemTemplate of repeater control

Discussion in 'ASP .Net Web Controls' started by msielski@gmail.com, Mar 31, 2005.

  1. Guest

    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
     
    , Mar 31, 2005
    #1
    1. Advertising

  2. Guest

    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...d1db4592d?q=repeater&rnum=37#095f0fdd1db4592d

    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
     
    , Mar 31, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bennett Haselton
    Replies:
    1
    Views:
    5,407
    Joe Fallon
    Sep 24, 2004
  2. Shimon Sim

    Repeater.ItemTemplate =?

    Shimon Sim, Jan 27, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    975
    Karl Seguin
    Jan 27, 2005
  3. Replies:
    3
    Views:
    1,687
    Eliyahu Goldin
    Aug 16, 2005
  4. boney
    Replies:
    1
    Views:
    605
  5. Stan
    Replies:
    2
    Views:
    207
Loading...

Share This Page