473,378 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Put results of a Function into HTML code


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
Jul 27 '06 #1
2 1152
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" <he********@yada.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>
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


Jul 27 '06 #2
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" <km*****@fxpress.comwrote in message
news:eK**************@TK2MSFTNGP06.phx.gbl...
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" <he********@yada.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>>
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



Jul 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: CharitiesOnline | last post by:
Hello, I have set this script up to add paging to a search results page. Which on the first page works fine. I calculates how many pages there should be depending on the number of results returned...
3
by: christopher.davidson | last post by:
Hello, I am working with XML files and utilizing Array functions to take the XML data and combined it with some html code to display a particular page. The process currently works like so: ...
0
by: tom | last post by:
Hi all, I'm having a bit of trouble getting my site to output a certain number of results per page. Any help on this would be greatly appriciated. Without this function my code outputs all...
7
by: daveeboi | last post by:
..I have been strugling to get this part of my site working correctly even though I can't see anything wrong with my code. I am trying to search a database and display paged results. But everytime...
6
by: dmorand | last post by:
I'm having a little trouble with my ajax. I can see my results in IE, but not firefox. I'm assuming I'm missing some syntax somewhere. alert("Test " + results + testing); returns the values in...
1
by: russot00 | last post by:
I have 3 drop down menus that are used in a search to locate restaurants in a db. All of the drop down menus function, a search can be submitted with any combination of drop downs and the results are...
1
by: sxwend | last post by:
I am trying to use the following post results (http://www.thescripts.com/forum/thread189759.html) and add another requirement. I need to send the results to just the email addresses that the query...
2
by: Abneo | last post by:
Hi all, I am very new to Javascript and I am in some need of some help. I am creating a site that has a madlib. I got the madlib code but now I want the results of the madlib to display in...
7
by: ankitoshniwal | last post by:
Hello, I have been having this problem for the whole day today, so even after i googled for the solution i was not able to get one, so i had to post to this forum. I had checked the solutions...
3
pezholio
by: pezholio | last post by:
Hi, I'm having a bit of trouble using Google Maps and the Google Ajax Search API, I'm trying to take a postcode, geocode it and then calculate the distance between the that postcode and a second...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.