没有对象数据源的 SPGridView 过滤
我已经动态创建了 SPGridView (在共享点的代码隐藏中),一切都工作正常,分页、排序等...但我想在不使用 ObjectDataSource 的情况下进行过滤(我通过将对象数据源的 ID 分配给
Grid.DataSourceID = objectDatasourceID;
并过滤 来使用 ObjectDataSource 完成此操作)有效,但是当我编辑该行时,然后在更新时它不起作用)所以我删除了 ObjectDataSource 并从数据库获取了表的数据并分配给 Grid.DataSource = DataTable;和 Grid.DataBind();它工作正常,但是当我编写过滤代码
SPgv.AllowFiltering = true;
SPgv.FilterDataFields = "CODE_NAME";
SPgv.FilteredDataSourcePropertyName = "FilterExpression";
SPgv.FilteredDataSourcePropertyFormat = "{1} = '{0}'";
(SPgv 是 SPGridView,CODE_NAME 是列名称)
时,当我运行此代码时,菜单出现在列名称上,并且排序 asc 和 desc 也有效,但它当我单击菜单时,给我一个 javascript 错误,并且 CODE_NAME 列中的值没有出现,它说正在加载...但没有出现
任何有关不使用 ObjectDataSource 进行过滤的帮助将不胜感激,我不需要任何文本框,下拉菜单过滤 我想要相同的菜单(出现在 SPGridView 中)进行过滤,但没有 ObjectDataSource。
I have created SPGridView dynamically (in the codebehind for sharepoint), everything is working fine paging, sorting etc... but I want to do filtering without using ObjectDataSource (I have done it with ObjectDataSource by assigning the ID of object datasource to
Grid.DataSourceID = objectDatasourceID;
and filterig works but when I edit the row then while updating it is not working) so I removed ObjectDataSource and got the table's data from DB and assing to Grid.DataSource = DataTable; and Grid.DataBind(); and it is working fine but when I write the code for filtering like
SPgv.AllowFiltering = true;
SPgv.FilterDataFields = "CODE_NAME";
SPgv.FilteredDataSourcePropertyName = "FilterExpression";
SPgv.FilteredDataSourcePropertyFormat = "{1} = '{0}'";
(SPgv is the SPGridView, and CODE_NAME is the column name)
and when I run this code the menu appears on the column name, and also sorting asc and desc works but it gives me a javascript error when I click on the menu and the values in the column CODE_NAME does not appear, it says loading... but nothing appears
Any help regarding filtering without ObjectDataSource will be greatly appreciated, I dont want any Textbox, dropdown for filtering I want the same menu (which appears in the SPGridView) for filtering but without ObjectDataSource.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如您所知,SPGridView 的过滤与 ObjectDataSource 配合使用效果最佳。我建议添加一个下拉控件并将所选值传递到 CAML 查询以进行过滤。
SPGridView's filtering works best with ObjectDataSource, as you know. I suggest adding a drop down control and passing the selected value to your CAML query to filter.