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 5:31am
09hadi710
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  
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  

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

  Print Answers RSS
0 OriginalGriff 195
1 ProgramFOX 130
2 Maciej Los 105
3 Sergey Alexandrovich Kryukov 105
4 Afzaal Ahmad Zeeshan 82
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web01 | 2.8.1411022.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