Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET Gridview
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 4-Dec-12 4:31am
09hadi702
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

First add a hyperlink field to the gridview and then:
<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>
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 620
1 Maciej Los 610
2 CPallini 255
3 RyanDev 161
4 Peter Leow 125
0 OriginalGriff 5,784
1 Sergey Alexandrovich Kryukov 4,838
2 Peter Leow 3,009
3 Maciej Los 2,894
4 DamithSL 2,465


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 20 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100