我的[0]资料为二进制资料(图片), 
[0]的资料不是没有内容, 
但每次结果都是得到空的结果,
为何?  protected void gviewEmployees_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.Cells[0].Text.Length > 0)
            {
                e.Row.Cells[0].Text = "<img src='lookpic.aspx?no=" + e.Row.Cells[0].Text + "' width='50' height='50' />";
            }
            else
            {
                e.Row.Cells[0].Text = "空"; 
            }
           
        }    }   

解决方案 »

  1.   

    1.注意单元格的位置顺序 是不是所要的就是cells[0]2.注意if的条件,是不是所有值都是length>0
      

  2.   


     protected void gviewEmployees_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (e.Row.Cells[0].Text!=""||e.Row.Cells[0].Text!=null)
                {
                    e.Row.Cells[0].Text = "<img src='lookpic.aspx?no=" + e.Row.Cells[0].Text + "' width='50' height='50' />";
                }
                else
                {
                    e.Row.Cells[0].Text = "空"; 
                }
               
            }    }   
      

  3.   

    最简单的方法,插入断点,进行调试,根据调试看值,很容易就能找出原因2楼的: if(e.Row.Cells[0].Text!=""||e.Row.Cells[0].Text!=null )
    可以简单写成: if(!string.IsNullOrEmpty(e.Row.Cells[0].Text)