c# - DevExpress - 设置单元格值 - mscorlib.dll 中发生类型为 'System.StackOverflowException' 的未处理异常

标签 c# gridview devexpress

我有这段代码(gridview,cellvaluechanged 事件):

      private void gv1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
string value1 = Convert.ToString(gv1.GetRowCellValue(gv1.FocusedRowHandle, "unitvalue"));
object cellValue = Convert.ToUInt32(value1) * Convert.ToInt32(days_worked);
 gv1.SetRowCellValue(gv1.FocusedRowHandle, "totalvalue", cellValue);
}

“days_worked”是从标签控件中获取的值,单元格的值不会改变, 出现以下错误:“System.StackOverflowException”类型的未处理异常发生在 mscorlib.dll 中

“totalvalue”是我数据库的一列

请帮忙,谢谢!

最佳答案

如文档中所述

The CellValueChanged event fires in response to a cell's value being changed. The list below gives the possible reasons for this event being raised:

  • An end-user has closed an in-place editor after changing the editor's value.
  • A cell's value has been changed using the methods provided by Views. For instance, the SetRowCellValue method can be used for this purpose.

所以你需要按照建议文档更改你的代码

private void gv1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
    if (e.Column.Caption != "totalvalue") return; // if event in fire from cells in column "totalvalue"

    string value1 = Convert.ToString(gv1.GetRowCellValue(gv1.FocusedRowHandle, "unitvalue"));
    object cellValue = Convert.ToUInt32(value1) * Convert.ToInt32(days_worked);
    gv1.SetRowCellValue(gv1.FocusedRowHandle, "totalvalue", cellValue);
}

关于c# - DevExpress - 设置单元格值 - mscorlib.dll 中发生类型为 'System.StackOverflowException' 的未处理异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21449236/

相关文章:

c# - 覆盖 ASP.NET Boundfield 以支持 Dropdownlist 缺少最后一项功能

css - 选择响应式/流体网格框架/模板

c# - .Net 程序集解决困惑

c# - 如何根据用户输入的值创建验证范围?

c# - OnRowDataBound点击事件打开另一个gridview

jquery - 单击 gridview 内的链接按钮时无法触发 jquery 警报

winforms - Devexpress PopupContainerEdit 弹出窗口始终打开

c# - DevExpress MVC 控制每个页面加载生成 2mb 的 javascript

c# - Windows 窗体内存泄漏

c# - 使用 Window.Open 而不是 Response.Redirect 打开新窗口?