如题,否则显示一大堆0太难看了。

解决方案 »

  1.   

    用模板列
    绑定时<%DataBinder.Eval(Container.DataItem,"字段名").ToString()=="0"?"":DataBinder.Eval(Container.DataItem,"字段名")%>
      

  2.   

    if(e.Item.Cells[3].Text=="0")
    {
        e.Item.Cells[3].Text="dd";
    }
      

  3.   

    to ymyang() 
    提示:
    编译错误 
    说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。 编译器错误信息: BC30451: 名称“Container”未声明。
      

  4.   

    private void NewDataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
    {
    if(e.Item.Cells[11].Text=="0")
    {
    e.Item.Cells[11].Text=="ZERO";
    }
    }
    }
      

  5.   

    //cs文件中加入
    public string FormatString(string str)
    {
      if(str != null && str.length > 0)
      {
        if(str == "0")
          str = "输入你要变换的值";
      }
      return str;
    }
    //前台
    <%FormatString(DataBinder.Eval(Container.DataItem,"字段名").ToString%>
      

  6.   

    使用模板列。在模板列中加一Label。它的Text绑定为:GetTitle(DataBinder.Eval(Container,"DataItem.字段名").ToString())在CS文件中写入以下方法:(注意public)public string GetTitle(string Title)
    {
       string NewTitle;
       if (Title=="0")
             NewTilte="你想替换的值";
       else
             NewTitle="又是你这种情况下想替换的值";   return NewTitle;
    }