2012-12-06 69 views
2

Deletebutton不會引發DevExpress的行刪除事件

我創建的DevExpress GridView控件上運行時,它s工作很好,直到單擊刪除按鈕,當我點擊它,它不會。對調試它不消防工作OnRowDeleting事件「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); 
+0

你怎麼知道RowDeleting事件沒有被觸發?你有沒有在你的grd_RowDeleting函數中設置一個斷點?你可以將這個函數添加到你的問題中嗎? – kenrogers

回答

2

您還沒有發佈完整的代碼,但在我看來,你沒有設置KeyFieldNameASPxGridView

文檔狀態:

如果未指定KeyFieldName屬性,下面的操作是不允許的:
- 數據編輯
- 添加新的和刪除現有行
- 選擇行