GridView1 RowDataBound
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的更多相关文章
- RowDataBound事件
RowDataBound事件在创建gridView控件时,必须先为GridView的每一行创建一个GridViewRow对象,创建每一行时,将引发一个RowCreated事件:当行创建完毕,每一行Gr ...
- GridView1 footer求和
// ShowFooter="True" private double sum = 0;//取指定列的数据和,你要根据具体情况对待可能你要处理的是int protected voi ...
- GridView的 PreRender事件与 RowCreated、RowDataBound事件大乱斗
GridView的 PreRender事件与 RowCreated.RowDataBound事件大乱斗 之前写了几个范例,做了GridView的 PreRender事件与 RowCreated.Row ...
- GridView控件RowDataBound事件中获取列字段值的几种途径 !!!
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == ...
- 类型“GridView”的控件“GridView1”必须放在具有 runat=server 的窗体标记内。
错误的写法: if (this.GridView1.Rows.Count > 0) { string style = @"<style& ...
- 错误提示:类型“GridView”的控件“GridView1”必须放在具有 runat=server 的窗体标记内 .
错误提示:类型“GridView”的控件“GridView1”必须放在具有 runat=server 的窗体标记内 在做导出数据到EXCEL程序中,出现了错误提示:类型“GridView”的控件“Gr ...
- GridView控件RowDataBound事件中获取列字段值的几种途径
前台: <asp:TemplateField HeaderText="充值总额|账号余额"> <ItemTemplate> <asp:Label ID ...
- GridView事件DataBinding,DataBound,RowCreated,RowDataBound区别及执行顺序分析
严格的说,DataBinding,DataBound并不是GridView特有的事件,其他的控件诸如ListBox等也有DataBinding,DataBound事件. DataBinding事件MS ...
- GridView的RowCreated与RowDataBound事件区别
在西门子面试时,项目负责人除了道试题关于RowCreated与RowDataBound事件区别,经过google一下,得出结果: GridView的RowCreated与RowDataBound的一个 ...
随机推荐
- luoguP1080 国王游戏 (贪心+高精度)
题目链接:https://www.luogu.org/problemnew/show/P1080 参考:https://www.luogu.org/problemnew/solution/P1080 ...
- Cocos2d-x 3.x 在wp8中调用系统字体的解决方案
问题和解决方法: 在使用cocos2d-x设计游戏的时候,字体是个很重要的部分.如果游戏中对字体没有太多的要求,就可以使用平台系统自带的字体,可以节省游戏的尺寸,以及减小游戏运行时所占用的内存.当加载 ...
- C++的编译与连接
编译器的任务是把我们人类通常能够读懂的文本形式的 C 语言文件转化成计算机能明白的目标文件.1. 预编译生成的仍然是.c文件1)把"include"的文件拷贝到要编译的源文件中. ...
- php5.4 trait 理解与学习
Trait 是 php5.4引入的新特性,手册上说的一大段没看懂,这里直接来过来. Trait 是为类似 PHP 的单继承语言而准备的一种代码复用机制.Trait 为了减少单继承语言的限制,使开发人员 ...
- Oracle登录命令
1.运行SQLPLUS工具 C:\Users\wd-pc>sqlplus 2.直接进入SQLPLUS命令提示符 C:\Users\wd-pc>sqlplus /nolog 3.以OS身份连 ...
- redhat安装xwindow环境
. yum groupinstall "X Window System" . yum groupinstall "GNOME Desktop Environment&qu ...
- ERR_UNSAFE_PORT
报错: 解决办法:
- QTextCodec 类
https://blog.csdn.net/qq_23948025/article/details/45500637
- 20155328 2016-2017-2 《Java程序设计》第7周学习总结
20155328 2016-2017-2 <Java程序设计>第7周学习总结 教材学习内容总结 时区 Date与DateFormat Date只用来获取epoch毫秒数 DateForma ...
- 2018.06.29 NOIP模拟 Minimum(最小生成树)
Minimum 题目背景 SOURCE:NOIP2015-SHY-2 题目描述 给出一幅由 n 个点 m 条边构成的无向带权图. 其中有些点是黑点,另外点是白点. 现在每个白点都要与他距离最近的所有黑 ...