Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Put results of a Function into HTML code

Reply
Thread Tools

Put results of a Function into HTML code

 
 
Henry Jones
Guest
Posts: n/a
 
      07-27-2006

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


 
Reply With Quote
 
 
 
 
Kasumo Morris
Guest
Posts: n/a
 
      07-27-2006
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>
> 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
>
>



 
Reply With Quote
 
 
 
 
Henry Jones
Guest
Posts: n/a
 
      07-27-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>>
>> 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
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Possible to put HTML page source into a variable? laredotornado Javascript 3 06-01-2011 08:38 PM
How to put const into function pointer? Immortal_Nephi@hotmail.com C++ 4 09-10-2008 08:54 AM
why does the following with Queue, q.put('\x02', True) not put itin the queue? Gabriel Rossetti Python 3 04-25-2008 03:41 PM
Put variables into member variables or function variables? tjumail@gmail.com C++ 9 03-23-2008 04:03 PM
How to put database results into an array? Haydnw ASP .Net 4 08-16-2004 07:36 PM



Advertisments