Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi, I have been trying to get this straight but the requirements changed and now I cant seem to get it working. I am getting Data from an access database, and in that data there is an attribute titled "LINK_STATUS" which is a binary column. The values are limited to 0 and 1. First I was tasked to change the color of the rows as red or green based on link status i.e. 0 for red and 1 for green. I did that but now I have been told to add a column to the gridview that will contain .gif animations. I have to display Green blinking .gif for 1 and Red for 0. I have been trying to get it done for a long time, anyone please help me?
Posted

Use two image files 0.gif (for red) and 1.gif (for green). Read LINK_STATUS from database and concatenate ".gif" to the value(0 or 1) and assign to the image column as Image file name
 
Share this answer
 
First add a hyperlink field to the gridview and then:
C#
<blockquote class="FQ"><div class="FQA">Quote:</div> if (e.Row.DataItem != null)
            {
                DataRowView drv = (DataRowView)e.Row.DataItem;
                string link_status = drv["link_status"].ToString();

                if (link_status == "0")
                {
                    TableCellCollection myCells = e.Row.Cells;
                    HyperLink planLink = (HyperLink)myCells[0].Controls[0];
                    planLink.ImageUrl = "~/gifs/red.gif";
                }
                else if (link_status == "1")
                {
                    TableCellCollection myCells = e.Row.Cells;
                    HyperLink planLink = (HyperLink)myCells[0].Controls[0];
                    planLink.ImageUrl = "~/gifs/green.gif";
                }
            }
            else
            { }</blockquote>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900