2

Deletebutton 不会引发 OnRowDeleting 事件

我在运行时创建了devexpress gridview,它运行良好,直到单击删除按钮,当我单击它时,它不起作用。在调试时它不会触发“行删除”。我能做些什么?

    dovizgrd.Width = Unit.Percentage(50);
    dovizgrd.EnableCallBacks = false;
    dovizgrd.Settings.ShowFooter = false;
    dovizgrd.Settings.ShowColumnHeaders = false;
    dovizgrd.Settings.ShowFilterBar = GridViewStatusBarMode.Hidden;
    dovizgrd.SettingsPager.Visible = true;
    dovizgrd.SettingsPager.Mode = GridViewPagerMode.ShowPager;
    dovizgrd.Styles.Header.Wrap = DevExpress.Utils.DefaultBoolean.True;
    dovizgrd.SettingsPager.PageSize = 10;

    DevExpress.Web.ASPxGridView.GridViewCommandColumn col0 =
    new  DevExpress.Web.ASPxGridView.GridViewCommandColumn();
    col0.ShowSelectCheckbox = true;
    col0.Caption = " ";
    col0.Width = Unit.Pixel(30);
    col0.VisibleIndex = 0;

    DevExpress.Web.ASPxGridView.GridViewDataTextColumn col1 =new DevExpress.Web.ASPxGridView.GridViewDataTextColumn();
                col1.FieldName = "example1";
                col1.Visible = false;
                col1.VisibleIndex = 1;

    DevExpress.Web.ASPxGridView.GridViewDataTextColumn col2 = 
    new DevExpress.Web.ASPxGridView.GridViewDataTextColumn();
                col2.FieldName = "example2";
                col2.Visible = false;
                col2.VisibleIndex = 2;

                DevExpress.Web.ASPxGridView.GridViewDataTextColumn col3 = new DevExpress.Web.ASPxGridView.GridViewDataTextColumn();
                col3.FieldName = "example3";
                col3.Caption = "Döviz Çeşidi";
                col3.Width = Unit.Pixel(100);
                col3.VisibleIndex = 3;

                DevExpress.Web.ASPxGridView.GridViewCommandColumn col4 = new DevExpress.Web.ASPxGridView.GridViewCommandColumn();
                col4.Caption = " ";
                //col4.EditButton.Visible = false;
                col4.DeleteButton.Visible = true;
                //col4.NewButton.Visible = false;
                col4.ButtonType = ButtonType.Image;

                col4.DeleteButton.Image.Url = "~/Images/icons/delete.gif";

                col4.Width = Unit.Pixel(35);
                col4.VisibleIndex = 4;

                dovizgrd.Columns.Add(col0);
                dovizgrd.Columns.Add(col1);
                dovizgrd.Columns.Add(col2);
                dovizgrd.Columns.Add(col3);
                dovizgrd.Columns.Add(col4);
                grdPH.Controls.Add(dovizgrd);
                dovizgrd.DataBind();

                dovizgrd.RowDeleting += new      DevExpress.Web.Data.ASPxDataDeletingEventHandler(grd_RowDeleting);
4

1 回答 1

2

您尚未发布完整的代码,但在我看来,您尚未在ASPxGridView上设置KeyFieldName

文档指出:

如果未指定 KeyFieldName 属性,则不允许进行以下操作:
- 数据编辑
- 添加新行和删除现有行
- 选择行

于 2012-12-07T08:05:16.287 回答