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. java内存模型:Happens-Before

    有序性:Java内存模型中的程序天然有序性可以总结为一句话:如果在本线程内观察,所有操作都是有序的:如果在一个线程中观察另一个线程,所有操作都是无序的.前半句是指“线程内表现为串行语义”,后半句是指“ ...

  2. spine

    spine 英 [spʌɪn] 美 [spaɪn]  n.脊柱;[动,植] 棘,刺(如刺猬和海胆的刺);鱼鳍的刺;植物上的刺

  3. 使用HttpModule实现网址重写

    1.  修改配置文件: <httpModules> <</span>add name="html" type="HttpModule&quo ...

  4. 网页flash播放代码

    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100%" hei ...

  5. .net core webapi 部署windows server 2008 r2 笔记

    WebAPI部署文档 安装dotnet-dev-win-x64.1.0.4 安装DotNetCore.1.1.0-WindowsHosting 安装vc_redist.x64 安装Windows6.1 ...

  6. 国内maven仓库地址

    Maven 中央仓库地址: 1.http://mvnrepository.com/ (推荐) 2.http://mirrors.ibiblio.org/maven2/ 3.http://repo1.m ...

  7. Eloquent Observer 的小坑

    前言 最近开发新的项目不是基于完整的 laravel 框架,框架是基于 laravel ORM 的简单MVC模式.随着项目的成熟和业务需求,需要引入事件机制.简单地浏览了一下 symfony.lara ...

  8. [BAT]win7下用批处理脚本自动删除7天以前创建的文件

    set JmeterPath=D:\apache-jmeter-2.7 forfiles /p %JmeterPath%\extras /m *.html -d -7 /c "cmd /c ...

  9. source Insight工程的简单使用

    本文以管理虚拟机里面的uboot为例: 1.选择project->New project->选择工程路径,假设为D:\uboot:->project has its own conf ...

  10. Silverlight或WPF动态绑定图片路径问题,不用Converter完美解决

    关于Silverlight或WPF动态绑定图片路径问题,不用Converter完美解决, 可想,一个固定的字符串MS都能找到,按常理动态绑定也应该没问题的,只需在前面标记它是一个Path类型的值它就能 ...