当我尝试对 GridView 进行排序时,系统返回此错误消息:
gridview sort An unhandled exception of type 'System.StackOverflowException' occurred in System.Web.dll
这是代码,“Melder”是要排序的列的名称。
gvOutlookMeldingen.Sort("Melder", SortDirection.Ascending);
最佳答案
您可能在 gvOutlookMeldingen_Sorting
中调用了 Sort()
,这将再次调用 gvOutlookMeldingen_Sorting
和 Sort()
,从而产生一个循环。
在 Sorting
事件中,您需要调用更改数据源的函数并再次执行查询。或者,如果它是自动绑定(bind)的,则您无需执行任何操作。
资源
- Sorting文档
关于c# - 对 GridView 进行排序时出现“System.StackOverflowException”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5946376/