欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

GridView1 RowDataBound

程序员文章站 2023-02-21 21:30:45
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add... ......
 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 = "#";
                }
            }
        }