zoukankan      html  css  js  c++  java
  • 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>

  • 相关阅读:
    前端cookie操作用到的一些小总结
    sublime 官方正版,自己用的插件配置,最轻量级安装流程
    Node.js 终端输出颜色设置
    Mac中设置别名 (转载)
    Swift 3 使用objc_setAssociatedObject
    ruby 笔记
    编程模式
    rvm pod gem 等常用命令
    node.js 笔记
    Node.js 对象合并
  • 原文地址:https://www.cnblogs.com/zclaude/p/9894971.html
Copyright © 2011-2022 走看看