gridview asp.net中的GIF c# [英] GIFs in gridview asp.net c#
问题描述
我一直在努力做到这一点,但要求已经改变,现在我似乎无法让它发挥作用。我从访问数据库获取数据,在该数据中有一个标题为LINK_STATUS的属性,它是一个二进制列。值限制为0和1.首先,我的任务是根据链接状态将行的颜色更改为红色或绿色,即红色为0,绿色为1。我这样做但现在我被告知要在gridview中添加一个包含.gif动画的列。我必须显示绿色闪烁.gif为1和红色为0.我一直试图让它完成很长一段时间,有人请帮助我吗?
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?
推荐答案
使用两个图像文件0.gif(红色)和1.gif(绿色)。从数据库中读取LINK_STATUS并将.gif连接到值(0或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
首先将超链接字段添加到gridview,然后:
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>
这篇关于gridview asp.net中的GIF c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!