你的ADD是在哪里写的,请确保在INIT,LOAD里面做

解决方案 »

  1.   

    我自己写了个继承datagrid的对象,在类里面写的方法。是在load里做的啊。
      

  2.   

    这是grid类的设置列的方法
    public bool SetColStyle(System.Data.DataTable dtConfig)
    {
        this.AutoGenerateColumns = false;
        System.Web.UI.WebControls.BoundColumn Col;
        for (int i = 0;i < dtConfig.Rows.Count ;i ++)
    {
       if ((string)dtConfig.Rows[i]["ColFullName"]!= "a.CName")
    {
    Col = new BoundColumn(); 
    Col.HeaderText = (string)dtConfig.Rows[i]["CName"];
    Col.DataField = (string)dtConfig.Rows[i]["ColFullName"];
    Col.SortExpression = (string)dtConfig.Rows[i]["ColFullName"];
    int intDateType;
    intDateType =(int)dtConfig.Rows[i]["DataType"];
    switch(intDateType)
    {
    case 2: Col.ItemStyle.HorizontalAlign =   System.Web.UI.WebControls.HorizontalAlign.Right;  
    Col.DataFormatString = "{0:N}";   
    break;
    case 3:
    Col.DataFormatString = "{0:d}";   
    break;
    }
    this.Columns.Add(Col);
    }
    }
    return true;
    }
      

  3.   

    AllowSorting 属性设置了没有。我以前也这样做过,不过可以排序
      

  4.   

    AllowSorting 当然设了,在页面中设的,会有问题吗
    我也在该方法中设过,不过也没有用
      

  5.   

    动态生成的如果你需要保持上一次的状态,那么你需要在每一次回发(Page_Load)都执行生成代码