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. <cctype>库

    http://www.cplusplus.com/reference/cctype/ 函数名称 返回值 isalnum() 如果参数是字母数字,即字母或数字,该函数返回true isalpha() 如 ...

  2. Python float() 函数

    Python float() 函数  Python 内置函数 描述 float() 函数用于将整数和字符串转换成浮点数. 语法 float()方法语法: class float([x]) 参数 x - ...

  3. Majority Element(ARRAY-BINARY SEARCH)

    QUESTION Given an array of size n, find the majority element. The majority element is the element th ...

  4. VS 窗体大小

    锁定窗体大小,就是鼠标停在窗口边框的时候,不能拖动来改变它的大小…… 有两种方法: 1.可以把Form的属性 FormborderStyle 后面选择 FixedDialog 2.或者把Form窗体的 ...

  5. 理解dynamic programming动态规划

    何谓动态规划? 以菲波那切数列为例, int fib(int n ){ if(n == 0 || n ==1){ return 1; }else{ return fib(n - 1) + fib(n ...

  6. 配置静态IP

    网卡配置静态IP地址编辑文件/etc/network/interfaces:sudo vi /etc/network/interfaces并用下面的行来替换有关eth0的行:# The primary ...

  7. VC字符串处理整理

    场景: 1.在存储数据时有时接口需要合并字符串值,并以某些特殊字符来合并部分,到需要的时候再分割它.如一些数值,人名等. 2.C++有strtok,stringstream和find函数来实现分割.可 ...

  8. mysql自定义函数收集

    代码: 查找字符串 in_string 中,存在多少个字符串 in_find_str delimiter $$ DROP FUNCTION IF EXISTS `fn_findCharCount` $ ...

  9. BZOJ 2726 [SDOI2012] 任务安排 - 斜率优化dp

    题解 转移方程与我的上一篇题解一样 : $S\times sumC_j  + F_j = sumT_i \times sumC_j + F_i - S \times sumC_N$. 分离成:$S\t ...

  10. 结构体的sort【防止遗忘w】

    #include<iostream> #include<algorithm> using namespace std; int n; struct jie { int num; ...