以编程方式向RadGrid添加事件处理程序

时间:2014-07-22 14:21:35

标签: c# telerik-grid radgrid

我已经以编程方式创建了一个RadGrid,并尝试将BatchEditCommand绑定到它,但是在点击多个保存后它不会更新并消失。 BatchEditCommand根本没有被触发,不知道发生什么事件,我很难调试,也许我在创建RadGrid时错过了一些重要的设置?

for (int i = 1; i <= 1; i++)
{
    strategy = strategy + Convert.ToString(i);
    RadGrid RadGrid_Strategy = new RadGrid();
    RadGrid_Strategy.ID = strategy;
    RadGrid_Strategy.Skin = "Office2010Blue";
    RadGrid_Strategy.GridLines = System.Web.UI.WebControls.GridLines.Both;
    RadGrid_Strategy.DataSource = GetDataTableForStrategy(CY, i);
    RadGrid_Strategy.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top;
    RadGrid_Strategy.ShowHeader = false;
    RadGrid_Strategy.BatchEditCommand += new GridBatchEditEventHandler(RadGrid_BatchEditCommand);
    RadGrid_Strategy.MasterTableView.EditMode = GridEditMode.Batch;
    RadGrid_Strategy.MasterTableView.BatchEditingSettings.EditType = GridBatchEditingType.Cell;
    RadGrid_Strategy.AllowAutomaticUpdates = true;
    RadGrid_Strategy.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = false;
    RadGrid_Strategy.MasterTableView.CommandItemSettings.ShowSaveChangesButton = true;
    RadGrid_Strategy.MasterTableView.CommandItemSettings.ShowCancelChangesButton = true;
    PlaceHolder1.Controls.Add(RadGrid_Strategy);
    RadGrid_Strategy.Rebind();
}

BatchEditCommand根本没有触发:

protected void RadGrid_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
{...}

1 个答案:

答案 0 :(得分:0)

您尝试调用的事件只有在您对网格进行更改时才会被触发,然后从RadGrid的BatchEditingManager调用任何这些客户端函数:

  • 的SaveChanges(的tableView)
  • saveAllChanges()
  • saveTableChanges(tableViews)

在Telerik论坛上查看this thread以获取更多信息。