how do I conditionally change bkg color of datalist cell and make the content of the cell clickable

Hi all,

1) how do I change background color of a datalist cell based on an attribute value (of a xml file) and make the content of the cell clickable ?

2) assuming the datalist is in an iframe. How do I make the cell content value available to another iframe page via clickable/url passing technique?

 Thanks

0
tvfoto
1/29/2007 9:48:51 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies
598 Views

Similar Articles

[PageSpeed] 24

Here's how to change the color (BALANCE_COL is the cell index):

    protected void GridViewFun_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.DataItem == null)
                return;
            
            // turn negative amounts red
            Decimal Amount;
            Amount = (Decimal)DataBinder.Eval(e.Row.DataItem, "CustomerBalance");
            if (Amount < Decimal.Zero)
                e.Row.Cells[BALANCE_COL].ForeColor = System.Drawing.Color.Red;
        }
    }
 
Steve Wellens

My blog
0
SGWellens
1/30/2007 1:46:38 AM
Reply:

Similar Artilces:

datalist: changing the background-color of a cell depending on the content
hallo,I have a datalist and I would like to display each cell with a different background depending on its content.I think the onitemdatabound event is the one to go for, but all the examples I found they are about datagrid and not datalist.... it should be the same (I guess), but there is also another difference: in my datalist I would display the content like that (witohut using labels): <asp:Datalist id="Datalist_1" runat="server" RepeatLayout="table" RepeatColumns="26"OnItemDataBound="Datalist1_ItemDataBound"OnItemCreated="Datalist1_ItemCreated"cssclass="tbl_menu"> <itemtempla...

Make Gridview cell value a hyperlink and change color of font conditional
Hello: I have a gridview displaying information about a project.  One of the columns of the record is the unique "id" and another column called "status" is the status of that record (i.e. New, Queue, Approved, etc).  I would like to do the following in VB code behind... If the Status of the record is equals "Queue" then make the font color of the word "Queue" maroon and make the word "Queue" a hyperlink to another page and pass the unique id of that record to that page.  I can get this to work with an edit...

Change cell color in a cell when hyperlink is clicked
I have a table across the bottom of my form, when a user clicks a hyperlink in one of the cells, I want the bgcolor of the cell to change. You can use the onClick event of the cell to change its bgcolor property. For example:<td bgcolor="black" onclick"bgcolor='white';">This is a test!</td>This uses event propogation to capture the click event which is passed down from the link. Steven BeyRecursion: see Recursion Don't know what I'm doing wrong, I used your example and it it doesn't want to cooperate. The bgcolor automatically deafults to the oncli...

datalist cell color change
i have a form which presents a list of access database records bound to a datalist. I have a column which displays all the due_dates. What i would like to do is change the colour of the entire row whenever there is a due_date record which is less than the current date. I am using vb.net behind my aspx page. Any ideas as to a basic function i would use here?   Thankyou Translated from C#:  Protected Sub DataList1_ItemDataBound(ByVal sender As Object, ByVal e As DataListItemEventArgs) Dim DVR As DataRowView = TryCast(e.Item.DataItem, DataRowView) If DVR IsNot Nothing...

Change Datagrid cell color based on cell value
I was wondering if there is a way to change the background color of an individual cell in a datagrid based on it's value. (I code in VB) Example: I have a Due Date field and the cells need to be highlighted yellow for all dates that are over 30 days old. Then for all of the dates that are over 60 days old, their cell backgrounds would need to be red. Thanks for the help in advance Dan Take a look @ Change Color of a Column Based on Column Values In your case you can use <Table> tag and change the <td> background color using helper function HTH Sushila ...

change grid cells back color (Cells Blinks)
Dear devs my case is im building a website similar to stocks websites, i used ajax for refreshing issues and gridview for disiplaying data. now the data will change frequently and i want to color the changed data (coloring the cells of changed data). but the problem is i dont know which cell is changed and which one staied remain. thanks for helpingJaffar N. Khalid Hi:   From your description my understanding is that you're using UpdatePanel and a Timer. Is it right? If my understanding is correct you can get the original data before GridView is bound again. Store it in a globa...

Changing a Cells color based on another cells value
We want to change the color of a previous cell based on the value in the current cell. For example, say we are ranking items as they are read into the datagrid. We have several columns of data we want to rank for first and second place. Once we encounter a value that is greater than the previous high value we would like to change the previous high values cell color to yellow and the new high cells color to green. For example column 1 in the following table would have 12 highlighted in green and 10 highlighted in yellow. See the following table. Column 2 would have 11 highlighted green and th...

To change the color of a cell in a table control
I am in desparate need of this.. i would like to know how to change the color of a single cell in a table using a button click or clicking the corresponding cell itself... pls divrt me to the solution in ASP.NET uisng C# code. Are you refering to HTML Table or GridView?Regards,Vinz"Code, Beer and Music" that's my way of being a programmer!How to get your Forum Question Answered | Blog | CodeASP.NET It is a normal HTML table.   Try out this one  <td id="tdTest" onclick="this.style.backgroundColor='blue'" /> or ...

How do I make the cell clickable in the calendar control?
Hi everybody! I'm looking for a way to make a whole cell clickable in the calendar control? Anybody can help me with this or post me an example, because I haven't found it on te internet. Thanks a lot! Frederick The ASP.NET calendar control was designed to use a hyperlink around the date number to post back. I am unaware of anyway to work around it. (Perhaps someone else knows.) I wanted to let you know that there are alternatives to the ASP.NET calendar control that may address this issue and perhaps offer you other options. For example, I wrote a replacement to the ASP.NET Ca...

Changing cell colors in a datagrid based on the information contained in the cell
Any help I can get would be greatly appreciated. I have a datagrid with information in several columns that show the status of certain aspects of a given project. Red for an area in trouble in trouble, yellow for those having problems that could become serious and green for those running as planned. What I would like to do is have the cell color change to correspond to the status of the project. Since the project managers update the status of projects as needed the color would need to change based on the text entered into the cell turning either red, yellow or green to correspond. H...

Aligning Datalist Cells Compared To Other Datalist Cells
I've got datalist cells that I cannot get to align with the cell next to them unless there's exactly the same amount of info in each of them. IE: (hope this displays right :) )    CELL1 TITLE     info                              CELL2 TITLE     info                       ...

Changing DataGrid cells and child controls based on other cells values... having trouble
I am trying to examine the value of one cell, then disable other controls in the same row (in other cells) based on this. Basically if this cell = Yes or No, then disable a dropdown in another cell. I have tried the ItemCreated and ItemDataBound and am intercepting the event.itemtype by (ListItemType.Item and ListItemType.AlternatingItem) but it is telling me that value of this cell when i examine it is empty. Should i wrap the value in a label or something? I have tried that as well but it doesnt work, the value is always empty when checking during these events but at render time ...

Making a cell within the calendar control clickable
Hello, I need help in making the whole cell, within the calendar control have a click event. This is so the user doesn't have to click on the text within the cell.   Here is what I have tried to add in the calendar1.dayrender event e.Cell.Attributes.Add("onclick", "parent.body.location.replace('calendar.aspx?dater=" & e.Day.[Date].ToString("MM/dd/yyyy") & "')")  When I click on it, I get an undefined object error. Your help is greatly appreciated.Just a regular dude that needs help every once in a while :) i m not ...

Make a calendar cell change color on mouse over
Hi,  Please tell me, how do I make a calnedar cell change color on mouse over event. I am working in Visual Studio 2005 using vb.net. Thanks, Shivani Start by knowing this fact: The DayRender event provides you with a Cell control. It is the control that needs the mouseover. So setup the DayRender event. There are two ways for mouseovers. 1. DHTML - This works with more browsers, but is more complex and creates far more HTML output, because each cell will get its own copy of the scripts. Start with e.Cell in DayRender. You can assign scripts like this:e.Cell.Attributes.Ad...

Web resources about - how do I conditionally change bkg color of datalist cell and make the content of the cell clickable - asp.net.presentation-controls

MOC conditionally approves Nokia-Microsoft deal
According to the announcement by the Ministry of Commerce, the Ministry is in the point of view that...

Christie Conditionally Backs New Jersey Internet Gambling
New Jersey Governor Chris Christie Thursday gave his conditional support to Internet gambling, laying the ground for the state to become one ...

N.Y.U. returns, conditionally, to salvage LICH deal
SUNY and Fortis bring hospital back, but only if judge dismisses nurses' union suit

Maltese PM says Greece would conditionally suspend bailout referendum
Greece has said it would be willing to suspend Sunday's planned referendum on the latest cash for reforms offer from its creditors if talks were ...

China approves conditionally Western Digital's acquisition of Hitachi
China has approved with conditions Western Digital's planned acquisition of Hitachi Global Storage Technologies (GST), requiring that the Hitachi ...

Chris Christie approves medical marijuana for children – conditionally
Christian Science Monitor Chris Christie approves medical marijuana for children – conditionally (+video) Christian Science Monitor Enlarge. ...

Chris Christie 'conditionally vetoes' minimum wage increase, Democrats saying screw your conditions
New Jersey Gov. Chris Christie conditionally vetoed a bill raising the state's minimum wage from the federal rate of $7.25 to $8.50 and tying ...

Chris Kluwe Conditionally Surrenders No. 5 To New Vikings QB Donovan McNabb
Your morning roundup for July 30, the day we're provided with living proof that 32-year-old women are, in fact, into 83-year-old men. Got any ...

MOEA conditionally approves Sanan Optoelectronics stake in Epistar
Taiwan's Ministry of Economic Affairs (MOEA) on October 29 approved the conversion of China-based LED epitaxial wafer and chip maker Sanan Optoelectronics' ...

Judge conditionally bars Samsung from pointing next week's jury to the Apple-HTC settlement deal
... construction) to a greater extent than on commercial considerations (such as the eBay injunction factors). However, I find her order conditionally ...

Resources last updated: 12/18/2015 8:49:24 AM