1

这是我的列类,我已将此代码添加到我的 radgrid

    using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Telerik.Web.UI;

namespace EFDemo.Views.Controls
{
    public class HpGridButtonColumn : GridButtonColumn{
        public string LinkedTab;

        public override void InitializeCell(System.Web.UI.WebControls.TableCell cell, int columnIndex, Telerik.Web.UI.GridItem inItem)
        {
            //if (inItem is GridHeaderItem)
            //{
            //    cell.Text = this.DataField;
            //}
            //if (inItem is GridDataItem)
            //{
            //    string ID = (string) inItem.OwnerTableView.DataKeyValues[inItem.ItemIndex]["CustomerID"];
            //    cell.Controls.Add(new LiteralControl(ID));
            //}
            base.InitializeCell(cell, columnIndex, inItem);
        }

        public override GridColumn Clone()
        {
            HpGridButtonColumn col = new HpGridButtonColumn();

            //you should override CopyBaseProperties if you have some column specific properties
            col.CopyBaseProperties(this);

            return col;
        }

        protected override void CopyBaseProperties(GridColumn FromColumn)
        {
            base.CopyBaseProperties(FromColumn);
            ((HpGridButtonColumn)FromColumn).LinkedTab = LinkedTab;
        }
    }
}

protected void HPRadgrid_ColumnCreating(object sender, GridColumnCreatingEventArgs e)
{
    if ((e.ColumnType == typeof(HpGridButtonColumn).Name))
    {
        e.Column = new HpGridButtonColumn();
    }
}

问题是属性 [linkedTab] 未在回发时恢复。它是空的。此外,未调用列上的克隆方法。我认为这就是该物业未恢复的原因。

4

0 回答 0