用脚本实现,在itemdatabind 时候绑定脚本来实现

解决方案 »

  1.   

    把那几行改成摸版列``加入显示图片的控件 
    protected   void   gvDepartmentInfo_RowDataBound(object   sender,   GridViewRowEventArgs   e) 
            { 
                    if   (e.Row.RowType   ==   DataControlRowType.DataRow) 
                    { 
                                //写个循环``判断下是晴还是雨更改相应的控件显示图片 
                    } 
            }
      

  2.   


    <itemtemplate>
    <asp:Image id="imgProduct" runat="server" ImageUrl='<%# Eval("ProductID")%>' width="60" height="60"></asp:Image></itemtemplate>protected void gvbList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    Image imageProduct = (Image)e.Row.FindControl("imgProduct");
                    imageProduct.ImageUrl = Resources.WebsiteInfo.urlImage + uImages.GetSmallPic(imageProduct.ImageUrl, "product");
                }
    }
      

  3.   

    已经解决了。谢谢。
     protected string GetImage(string str)
            {
                
                str = str.Replace("happy", "<img src='haha.gif'>");
                return str;
            }<ItemTemplate>
    <%#GetImage(Eval("Flag").ToString())%>
    </ItemTemplate>
      

  4.   

    我的是判断是否过期的 复值
    在RowDataBound事件里写的 :if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            DateTime overDate = Convert.ToDateTime(dt.Rows[i]["overDate"].ToString());
                            DateTime Nowtime = DateTime.Now;
                            int id;
                            if (overDate < Nowtime)
                            {
                                dt.Rows[i]["isOver"]="已过期";
                                id = Convert.ToInt32(dt.Rows[i]["repertoryInDetail_ID"].ToString());
                                bf.IsOverUpdate(id);
                            }
                            if (overDate > Nowtime)
                            {
                                dt.Rows[i]["isOver"] = "没过期";
                            }
                        }
                    }
      

  5.   

    判断是晴天还是雨天,然后设置一下IMG的SRC属性!