我的[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 = "空";
}
} }
[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 = "空";
}
} }
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 = "空";
}
} }
可以简单写成: if(!string.IsNullOrEmpty(e.Row.Cells[0].Text)