protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "this.name=this.className;this.className='selrow';");
e.Row.Attributes.Add("onmouseout", "this.className=this.name;"); string BWFlag = DataBinder.Eval(e.Row.DataItem, "BWFlag").ToString(); if(BWFlag == "B")
{
e.Row.Cells[3].Text = "黑名单";
}
else
{
e.Row.Cells[3].Text = "白名单";
}
//ModelBlackWhiteList model = row.DataItem as ModelBlackWhiteList;
LinkButton lkImage = e.Row.FindControl("lkImage") as LinkButton;
//Image imgCar = e.Row.FindControl("imgCar") as Image;
object CarPicPath = DataBinder.Eval(e.Row.DataItem, "CarPicPath");
if (CarPicPath != null)
{
lkImage.PostBackUrl = "ShowImage.aspx?CarPicPath=" + System.Web.HttpUtility.HtmlEncode(CarPicPath.ToString());
}
else
{
lkImage.PostBackUrl = "#";
}
}
}

<asp:BoundField DataField="BWFlag" HeaderText="黑/白名单" />
<asp:TemplateField HeaderText="车牌图片" ItemStyle-Width="100px">
<ItemTemplate>
<asp:LinkButton ID="lkImage" runat="server" CommandArgument='<%#Eval("Id") %>' CommandName="ShowImg" CssClass="btnedit">
<asp:Image ID="imgCar" runat="server" Height="40" ImageUrl='<%#Eval("CarPicPath")%>'/>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>

GridView1 RowDataBound的更多相关文章

  1. RowDataBound事件

    RowDataBound事件在创建gridView控件时,必须先为GridView的每一行创建一个GridViewRow对象,创建每一行时,将引发一个RowCreated事件:当行创建完毕,每一行Gr ...

  2. GridView1 footer求和

    // ShowFooter="True" private double sum = 0;//取指定列的数据和,你要根据具体情况对待可能你要处理的是int protected voi ...

  3. GridView的 PreRender事件与 RowCreated、RowDataBound事件大乱斗

    GridView的 PreRender事件与 RowCreated.RowDataBound事件大乱斗 之前写了几个范例,做了GridView的 PreRender事件与 RowCreated.Row ...

  4. GridView控件RowDataBound事件中获取列字段值的几种途径 !!!

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == ...

  5. 类型“GridView”的控件“GridView1”必须放在具有 runat=server 的窗体标记内。

    错误的写法:  if (this.GridView1.Rows.Count > 0)         {             string style = @"<style& ...

  6. 错误提示:类型“GridView”的控件“GridView1”必须放在具有 runat=server 的窗体标记内 .

    错误提示:类型“GridView”的控件“GridView1”必须放在具有 runat=server 的窗体标记内 在做导出数据到EXCEL程序中,出现了错误提示:类型“GridView”的控件“Gr ...

  7. GridView控件RowDataBound事件中获取列字段值的几种途径

    前台: <asp:TemplateField HeaderText="充值总额|账号余额"> <ItemTemplate> <asp:Label ID ...

  8. GridView事件DataBinding,DataBound,RowCreated,RowDataBound区别及执行顺序分析

    严格的说,DataBinding,DataBound并不是GridView特有的事件,其他的控件诸如ListBox等也有DataBinding,DataBound事件. DataBinding事件MS ...

  9. GridView的RowCreated与RowDataBound事件区别

    在西门子面试时,项目负责人除了道试题关于RowCreated与RowDataBound事件区别,经过google一下,得出结果: GridView的RowCreated与RowDataBound的一个 ...

随机推荐

  1. 几种常见的Web服务器

    Apache与Tomcat的区别 ,几种常见的web/应用服务器 APACHE是一个web服务器环境程序 启用他可以作为web服务器使用 不过只支持静态网页 如(asp,php,cgi,jsp)等动态 ...

  2. Coding Contest(费用流变形题,double)

    Coding Contest http://acm.hdu.edu.cn/showproblem.php?pid=5988 Time Limit: 2000/1000 MS (Java/Others) ...

  3. 运行php网站需要安装什么

    php的运行环境: 为了能够运行php,有以下两种方法: 1. 使用支持php和MySQL的web主机(): 2. 本机(自己电脑)安装web服务器,然后安装MySQL和php. web虚拟主机: 大 ...

  4. pyhon模块之日志模块

    #Auther Bob#--*--coding:utf-8--*-- import logging #python一共有5个级别的日志,debug.info.warning.error.critica ...

  5. memcache简单操作

    <?php $m = new Memcache(); $m->connect('localhost',11211); //获取版本 echo "server's version: ...

  6. SSL - 简介

    一.密码技术 要了解SSL协议,首先要了解:加密算法.消息摘要算法(又称为哈希算法Hash),数字签名等概念.这些技术每个都可以写出一整本的书,它们结合在一起,提供了保密性.完整性和身份验证的功能. ...

  7. laravel表单提交

    1.控制器->路由->视图 2.视图 3.控制器

  8. part1:10-TFTP与NFS服务器配置

    1.交叉开发 嵌入式系统开发多采用交叉开发模式,所谓嵌入式交叉开发就是指在宿主机上进行程序的编写,然后通过交叉编译生成目标机平台可以运行的二进制代码,最后再下载到目标平台上的特定位置运行.产生嵌入式软 ...

  9. Linux下JDK应该安装在哪个位置

    在百度知道上看到的回答觉得不错:https://zhidao.baidu.com/question/1692690545668784588.html 如果你认为jdk是系统提供给你可选的程序,放在op ...

  10. memcached 连接本地问题

    刚开始学memcache ,就遇到一个问题. telnet 127.0.0.1 11211   回车之后就什么都没有提示了.然后不管设置什么都是报error . 表示不知道如何解决!先写个文章记录下来 ...