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>

  • 相关阅读:
    shell遍历文件夹并执行命令
    安装PIL的坑
    iptables不小心把127.0.0.1封了,导致redis连不上
    python读取中文
    不要在基类析构函数中调用纯虚函数,否则运行时会报错“pure virtual method called”
    阿里云64位centos6.3系统上编译安装redis
    Git
    Easy Mock
    Sortable
    几个框架
  • 原文地址:https://www.cnblogs.com/zclaude/p/9894971.html
Copyright © 2011-2022 走看看