Setting style properties in datalist depending on DB-content

Discussion in 'ASP .Net Web Controls' started by Jon Henning Bergane, Sep 12, 2003.

  1. Hi newbie here,

    Is it possible to set for example the color of some data
    in a datalist which is bound to an SQLDatareader
    depending on what data is in the current record? Is there
    an event where i can read the current db-record and set
    the color of the text??
     
    Jon Henning Bergane, Sep 12, 2003
    #1
    1. Advertisements

  2. Jon Henning Bergane

    Slawek Guest

    Hi,
    There is an event ItemCreated for DataList - You can check every element and
    do what you want with it. (using Attributes)

    Slawek
     
    Slawek, Sep 12, 2003
    #2
    1. Advertisements

  3. So how could this be done here? i want to have
    Creationtime in another color.

    <asp:datalist id="dlArticles" runat="server" Font-
    Names="Verdana" Font-Size="11px">
    <ItemTemplate>
    <b>
    <%# Databinder.Eval
    (Container.DataItem, "Creationdatetime", "{0:t}")%>
    </b>&nbsp;<a href='article.aspx?RefID=<%#dr
    ("RefId")%>' target="mainart">
    <%#dr("ArticleTitle")%>
    </a><br>
    </ItemTemplate>
     
    Jon Henning Bergane, Sep 12, 2003
    #3
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.