devexpress行删除事件

时间:2012-12-06 13:20:23

标签: c# asp.net devexpress aspxgridview

Deletebutton不会引发OnRowDeleting事件

我在运行时创建了devexpress gridview,直到点击删除按钮,当我点击它时,它不起作用。在调试它不会触发“rowdeleting”。我该怎么办?

    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);

1 个答案:

答案 0 :(得分:2)

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

文档说明:

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