有个例子,仅供参考。
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;
}

解决方案 »

  1.   

    可以使用模板列,在header加入label 和image
      

  2.   

    使用DataGrid属性生成器,轻松搞定!
      

  3.   

    lrxz(九月鹰飞.Net) 
    Sort = "<img>";//这里加入图片
    这里怎么写,我试了一下,没成功
      

  4.   

    怎么,if((bool)ViewState["SortDesc"])   报错Object reference not set to an instance of an object. 
    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'>";//??????