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

public class MyCustomFilteringColumn : GridTemplateColumn
    {
        public string DataField
        {
            get
            {
                object res = this.ViewState["_df"];
                if (res != null)
                {
                    return (string)res;
                }

                return String.Empty;
            }
            set
            {
                this.ViewState["_df"] = value;
            }
        }

        protected override void SetupFilterControls(System.Web.UI.WebControls.TableCell cell)
        {
            base.SetupFilterControls(cell);
            cell.Controls.RemoveAt(0);
            cell.Controls.AddAt(0, new TextBox());
        }
        public override GridColumn Clone()
        {
            return base.Clone();
        }

        protected override string GetFilterDataField()
        {
            return this.DataField;
        }

        protected override void SetCurrentFilterValueToControl(TableCell cell)
        {
            base.SetCurrentFilterValueToControl(cell);
            if (this.CurrentFilterValue != "")
            {
                (cell.Controls[0] as TextBox).Text = this.CurrentFilterValue;
            }
        }

        protected override string GetCurrentFilterValueFromControl(TableCell cell)
        {
            return (cell.Controls[0] as TextBox).Text;
        }

        public override bool SupportsFiltering()
        {
            return true;
        }

    } 
}
