简体   繁体   English

不使用数据库的Asp.net网格视图的搜索功能

[英]Search functionality for an Asp.net gridview without using database

I am using a gridview and bind data to it from a SharePoint list. 我正在使用gridview并将数据从SharePoint列表绑定到它。

I want to know how to use search functionality for my gridview as I don't have any database. 我想知道如何对我的gridview使用搜索功能,因为我没有任何数据库。 (and the solutions I see all use a database) (我看到的解决方案全部使用数据库)

Is there any other solution apart from the JQuery plug-in DataTables?? 除了JQuery插件DataTables之外,还有其他解决方案吗?

Kindly Help! 请帮助! Thanks :) 谢谢 :)

I suggest to search through sharepoint list, not gridview. 我建议搜索共享点列表,而不是gridview。

using (SPWeb web = SPContext.Current.Web)
        {
            SPList list = web.Lists["list"];
            string title = "line for search";
            SPListItemCollection items = list.GetItems(new SPQuery()
            {
                Query = @"<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>" + title + "</Value></Eq></Where>"
            });
            if (items.Count > 0)
            {
                mygrid.DataSource = items.GetDataTable();
                mygrid.DataBind();
            }

        }

I suggest to use SPGridView instead of normal Asp.net Gridview when you specially working with SharePoint, into SPGridView you are able to access Filter property which is not exactly same as Search but apart from the "JQuery plug-in DataTables" it is far better. 我特别建议与SharePoint一起使用时,建议使用SPGridView而不是普通的Asp.net Gridview。在SPGridView中,您可以访问Filter属性,该属性与Search并不完全相同,但是除了“ JQuery插件DataTables”之外,它要好得多。 。

spGV.FilterDataFields = "Year,Title,,Name";
spGV.FilteredDataSourcePropertyName = "FilterExpression";

在此处输入图片说明

you can find complete Example here : https://code.msdn.microsoft.com/office/SPGRIDVIEW-EXAMPLE-47276dd4 您可以在此处找到完整的示例: https : //code.msdn.microsoft.com/office/SPGRIDVIEW-EXAMPLE-47276dd4

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM