有个例子,仅供参考。
if((bool)ViewState["SortDesc"])
{
Sort = "<img>";//这里加入图片
}
else
{
Sort = "<img>";//这里加入图片
}
this.dg_TypeZ.Columns[1].HeaderText = "Z轴类别(中文)";
this.dg_TypeZ.Columns[2].HeaderText = "Z轴类别(英文)";
this.dg_TypeZ.Columns[3].HeaderText = "X轴类别";
this.dg_TypeZ.Columns[4].HeaderText = "Y轴类别"; if(e.SortExpression == "TypeZ")
{
this.dg_TypeZ.Columns[1].HeaderText = "Z轴类别(中文)" + Sort;
}
else if(e.SortExpression == "TypeZEn")
{
this.dg_TypeZ.Columns[2].HeaderText = "Z轴类别(英文)" + Sort;
}
else if(e.SortExpression == "TypeXID")
{
this.dg_TypeZ.Columns[3].HeaderText = "X轴类别" + Sort;
}
else if(e.SortExpression == "TypeYID")
{
this.dg_TypeZ.Columns[4].HeaderText = "Y轴类别" + Sort;
}
if((bool)ViewState["SortDesc"])
{
Sort = "<img>";//这里加入图片
}
else
{
Sort = "<img>";//这里加入图片
}
this.dg_TypeZ.Columns[1].HeaderText = "Z轴类别(中文)";
this.dg_TypeZ.Columns[2].HeaderText = "Z轴类别(英文)";
this.dg_TypeZ.Columns[3].HeaderText = "X轴类别";
this.dg_TypeZ.Columns[4].HeaderText = "Y轴类别"; if(e.SortExpression == "TypeZ")
{
this.dg_TypeZ.Columns[1].HeaderText = "Z轴类别(中文)" + Sort;
}
else if(e.SortExpression == "TypeZEn")
{
this.dg_TypeZ.Columns[2].HeaderText = "Z轴类别(英文)" + Sort;
}
else if(e.SortExpression == "TypeXID")
{
this.dg_TypeZ.Columns[3].HeaderText = "X轴类别" + Sort;
}
else if(e.SortExpression == "TypeYID")
{
this.dg_TypeZ.Columns[4].HeaderText = "Y轴类别" + Sort;
}
Sort = "<img>";//这里加入图片
这里怎么写,我试了一下,没成功
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error:
Line 66: {
Line 67: string Sort;
Line 68: if((bool)this.ViewState["SortDesc"])
Line 69: {
Line 70: Sort = "<img src='../Images/Sort1.gif'>";//??????