SPGridView filtering without 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.
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.
精彩评论