如何覆盖GridView OnItemDataBound方法?

时间:2016-12-26 08:38:52

标签: c# asp.net override controls

我想制作服装Gridview。我找到了非常好的开源软件,但问题是它使用DataGrid,当我将继承的类更改为GridView时,我收到以下错误

  

AADGridView.OnItemDataBound(DataGridItemEventArgs   e):找不到合适的方法来覆盖

我在这里覆盖:

//public class AADGridView : DataGrid, IPostBackEventHandler
         public class AADGridView : GridView, IPostBackEventHandler
        {

            /// <summary>
            /// Gets or sets a value that indicates whether the auto filter is displayed in the AADGrid.AADGridControl.
            /// </summary>
            [Bindable(true), Category("Appearance"), Description("Whether to show the control's auto filter."), DefaultValue(true),]


            /// <summary>
            /// Override the DataGrid constructor.
            /// </summary>
            public AADGridView() : base()
            {
                // create the ArrayList to contain the DropDownList controls and the SortedList objects added to the header items;
                //list = new ArrayList();
                sort = new ArrayList();
                filter = true;
            }

            /// <summary>
            /// Override the OnItemDataBound event.
            /// </summary>
            /// <param name="e"></param>
            override protected void OnItemDataBound(DataGridItemEventArgs e)
            {
              //Some Code
               base.OnItemDataBound(e);
            }

正如您在代码中看到的,我只是将DataGrid更改为GridView。它们都有OnItemDataBound,那么问题是什么? 感谢

1 个答案:

答案 0 :(得分:0)

事件参数的类型为DataGridItemEventArgs。您必须将参数类型更改为新的基类&#39;参数。