Put results of a Function into HTML code

Discussion in 'ASP .Net' started by Henry Jones, Jul 27, 2006.

  1. Henry Jones

    Henry Jones Guest

    In ASP.NET 1.1, I have a Datagrid and I have the following column:

    <asp:TemplateColumn HeaderText="ID" ItemStyle-HorizontalAlign="Center"
    ItemStyle-BackColor="0066cc">
    <ItemTemplate>
    <%# DataBinder.Eval(Container.DataItem,"title_id") %>
    </ItemTemplate>
    </asp:TemplateColumn>


    Would it be possible to call the following function:
    ' ********************************************************************
    Function Highlight(ByVal ytdSales As Integer) As String

    If ytdSales > 10000 Then
    Return "#0066cc"
    Else
    Return "#0033aa"
    End If

    End Function
    ' ********************************************************************

    and replace the value on the TemplateColumn Header for the backcolor?

    How could I do this in code? I don't understand.

    Thanks,

    Henry
    Henry Jones, Jul 27, 2006
    #1
    1. Advertising

  2. Henry,

    You could iterate through the DataGrid items collection and set the
    BackColor
    ...
    grdListing.DataBind();
    foreach(DataGridItem item in grdListing.Items)
    {
    int ytdSales = int.Parse(item.Cells[0].Text);
    item.BackColor = Color.FromName(Highlight(ytdSales));
    }
    ...

    Hope this helps
    Kasumo.

    "Henry Jones" <> wrote in message
    news:%...
    >
    > In ASP.NET 1.1, I have a Datagrid and I have the following column:
    >
    > <asp:TemplateColumn HeaderText="ID" ItemStyle-HorizontalAlign="Center"
    > ItemStyle-BackColor="0066cc">
    > <ItemTemplate>
    > <%# DataBinder.Eval(Container.DataItem,"title_id") %>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    >
    >
    > Would it be possible to call the following function:
    > ' ********************************************************************
    > Function Highlight(ByVal ytdSales As Integer) As String
    >
    > If ytdSales > 10000 Then
    > Return "#0066cc"
    > Else
    > Return "#0033aa"
    > End If
    >
    > End Function
    > ' ********************************************************************
    >
    > and replace the value on the TemplateColumn Header for the backcolor?
    >
    > How could I do this in code? I don't understand.
    >
    > Thanks,
    >
    > Henry
    >
    >
    Kasumo Morris, Jul 27, 2006
    #2
    1. Advertising

  3. Henry Jones

    Henry Jones Guest

    Thanks for the reply.... but....

    Thanks for reply and I'll give your code a try, but I would like to find out
    if I can do what I originally requested. Is there a way replace the code in
    the TemplateColumnHeader by calling a function and if so, how can I do it?

    Thanks,

    Gary

    "Kasumo Morris" <> wrote in message
    news:...
    > Henry,
    >
    > You could iterate through the DataGrid items collection and set the
    > BackColor
    > ...
    > grdListing.DataBind();
    > foreach(DataGridItem item in grdListing.Items)
    > {
    > int ytdSales = int.Parse(item.Cells[0].Text);
    > item.BackColor = Color.FromName(Highlight(ytdSales));
    > }
    > ...
    >
    > Hope this helps
    > Kasumo.
    >
    > "Henry Jones" <> wrote in message
    > news:%...
    >>
    >> In ASP.NET 1.1, I have a Datagrid and I have the following column:
    >>
    >> <asp:TemplateColumn HeaderText="ID" ItemStyle-HorizontalAlign="Center"
    >> ItemStyle-BackColor="0066cc">
    >> <ItemTemplate>
    >> <%# DataBinder.Eval(Container.DataItem,"title_id") %>
    >> </ItemTemplate>
    >> </asp:TemplateColumn>
    >>
    >>
    >> Would it be possible to call the following function:
    >> ' ********************************************************************
    >> Function Highlight(ByVal ytdSales As Integer) As String
    >>
    >> If ytdSales > 10000 Then
    >> Return "#0066cc"
    >> Else
    >> Return "#0033aa"
    >> End If
    >>
    >> End Function
    >> ' ********************************************************************
    >>
    >> and replace the value on the TemplateColumn Header for the backcolor?
    >>
    >> How could I do this in code? I don't understand.
    >>
    >> Thanks,
    >>
    >> Henry
    >>
    >>

    >
    >
    Henry Jones, Jul 27, 2006
    #3
    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. Haydnw
    Replies:
    4
    Views:
    3,567
    Haydnw
    Aug 16, 2004
  2. Replies:
    9
    Views:
    929
  3. Gabriel Rossetti
    Replies:
    3
    Views:
    534
    Jerry Hill
    Apr 25, 2008
  4. Kathy Simmons

    parse xml file, put results in mysql db

    Kathy Simmons, Nov 16, 2006, in forum: Ruby
    Replies:
    0
    Views:
    157
    Kathy Simmons
    Nov 16, 2006
  5. laredotornado
    Replies:
    3
    Views:
    441
    Dr J R Stockton
    Jun 1, 2011
Loading...

Share This Page