1

I have a SharePoint list which is bound to an asp.net gridview, I further want to search every column.

Is there a way to perform such a search wherein there is no database, but search should be performed based on the values in the datatable of the gridview.

I have seen posts where a Jquery plug-in DataTable is used. But I would prefer actual code.

Kindly help. Thank you! :)

  • Are you want to implement search on asp.net grid view OR html table ? – SP Developer Aug 18 '17 at 11:23
  • on asp.net grid view @Vishal – Sanjana V Aug 22 '17 at 3:08
2

Place a search box and button on button click query your datasource i believe its List in this case

public void Search(string searchText)
    {
        ClientContext clientContext = new ClientContext("mySite");


            SP.List oList = clientContext.Web.Lists.GetByTitle("myList");

            SP.CamlQuery camlQuery = new SP.CamlQuery();
            camlQuery.ViewXml = @"<Query><Where><Eq><FieldRef Name='searchColum' /><Value Type='valType'>" + searchText + "</Value></Eq></Where></Query>";
            SP.ListItemCollection listItemColl = oList.GetItems(camlQuery);
            clientContext.Load(listItemColl);
            clientContext.ExecuteQuery();
            //Convert listItemColl to dataTable and bind grid

}

Refer the answer here You can reuse the code at link by creating the CAML query dynamically to query the List.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.