none
Custom search to document library to find specific document RRS feed

  • Question

  • Hi

    I have a document library with having multiple folders approx 100 (001 to 100) , each folder is having multiple document ,Every folder in that document library contains 50000 documents , Document library has some fileds like Fname, Lname,Document Type [Look up field] having value(Genral,Average,Advance) . now the problem is to search these documents with using custom search as per requirement

    the user wants a webpart where it has 2 textbox [FName and LName] and a dropdown [Document type] and a button , using this the user can enter the first name , last name and selecting document type from the dropdown and finally clicking the search button filters the document library. 

    my problem is with that how the value of this search criteria can be passed to the Document library.How these webpart can be connected with custom search or do we have any other way to search.

     

    Thanks

     

    Monday, October 4, 2010 3:25 AM

Answers

  • Hi San,

    I don't find other way except below:

    1. You can configure advanced search and define the properties. No coding require here

    2. Create custom webpart / SP web service as per your requirement.

    For your ref:

    http://www.codeproject.com/KB/aspnet/SPCustomSearchResults.aspx

    http://www.techbrij.com/229/sharepoint-search-in-document-library-list-programmatically

    Hope it helps


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
    Thursday, October 7, 2010 5:52 AM
    Moderator

All replies

  • Hi,

    Well, you can use CAML to search the entire document library structure, Recursive searching, enable it in your query with this tag,  "Scope='Recursive'";

    Now I am no expert in CAML, but you will find plenty of resources on recursive CAML queries on MSDN and other sites, here is one I found on StackOverflow, http://stackoverflow.com/questions/1557675/caml-query-that-includes-folders-in-result-set which is exactly what you need.

     

    Note, in SP 2010 you can use linq to sharepoint which is a lot more user friendly that CAML, by creating an entity framework using SPMETAL before hand, which will create a structure without content in a code file for you, and they way you use this query to accomplish your goal is listed below,

    var q = dc.Projects.ScopeToFolder("", true).Where(Your query parameters);

    In the ScopeToFolder() method, the first variable you leave blank and the bool value to true, this will enable recursive(include items in sub folders)

    Cheers

    Pieter

    Monday, October 4, 2010 7:32 AM
  • Hi San,

    Thanks to share your problem.

    You should create a custom webpart and use the CAML query to find the document within the library. You have to use sharepoint object model here

    Follow the steps:

    1. Create .net web application through visual studio

    2. Add a user control file like: .ascx and place the asp.net controls over the form (i.e. DDL, Button etc)

    3. Add sharepoint dll in your project (Microsoft.Sharepoint.dll)

    4. Use below code to connect your webpart with sharepoint

    using (SPSite mySite = new SPSite(webUrl))
              {
    using (SPWeb myWeb = mySite.OpenWeb())
              {

    SPList objLists = myWeb.Lists["Your doc library Name"];

    SPListItemCollection objItemcoll;

    SPQuery objQuery = new SPQuery();

    objQuery.Query = "<Where><And><Eg><FieldRef Name='FName'/><Value Type='Text'>" + Your Input value of FName + "</Value><FieldRef Name='LName'/><Value Type='Text'>" + Your Input value of LName + "</Value></Eq></And></Where>";

    objQuery.ViewAttributes = "Scope=\"Recursive\""; \\It will get only document from library

    objItemcoll = objLists .GetItems(objQueryInternet);

      if (objItemcoll.Count > 0)
       {

        foreach (SPListItem item in objItemcoll)

        {

    /////Bind your datagrid here

    }

    }}}

    5. Add one Class1.cs file in your application. (Thsi will render your custom control)

    6. Add following code in your in Class1.cs file

    public class Class1 :WebPart
        {
            private UserControl uc;
            protected override void CreateChildControls()
            {
                uc = (UserControl)Page.LoadControl("~/_layouts/Usercontrol.ascx");
                this.Controls.Add(uc);
            }
        }

    7. Rebuild your whole application and put your application dll in Bin folder of your site virtual directory

    8. Make  a safe control entry and add webpart in your site using webpart gallery

    9. Add your control wherever you want

    Ref: http://www.reflectionit.nl/smartpart.aspx

    let me know if it works. If you find any problem in this then let me know


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
    Monday, October 4, 2010 8:37 AM
    Moderator
  • Hi Hemendra/Pieter,

    Thanks for your reply , my concern is that once the document llibrary data gets bind with these control (Gridview,Datagrid or spGrid),

    how would the properties of document library (Check in, chekout,download,launch workflow etc) gets invoke with this Data grid or SPGrid .Do we have any way that we can use Datagrid or SPgrid can be looks like a Document library and can do chekin and chekout or otherway can we customize the Document library for search as we like using webpart connection.

    I don't think Sharepoint has any feature that helps to search the document based on the field entered in the respective columns in that document library. As document library will be shown as a webpart on a page, how my custom search webpart (created in dotnet control page) value get passed as a parameter to document library webpart on the same page and filter the documents based on the search criteria on the respective columns.

     

    Thanks

    San

    Tuesday, October 5, 2010 7:07 PM
  • Hi San,

    Check in, checkout and download can be handled at coding level and once item is added / modify in library, the workflow will be started automatically. Workflow is handled by sharepoint itself.

    Let me know if you have any query


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
    Wednesday, October 6, 2010 3:43 AM
    Moderator
  • Hemendra,

    I dont want to do too much coding out of box , can this problem be solved using webpart connection

    rather doing big line of code.

    Thanks

    Wednesday, October 6, 2010 4:52 PM
  • Hi San,

    I don't find other way except below:

    1. You can configure advanced search and define the properties. No coding require here

    2. Create custom webpart / SP web service as per your requirement.

    For your ref:

    http://www.codeproject.com/KB/aspnet/SPCustomSearchResults.aspx

    http://www.techbrij.com/229/sharepoint-search-in-document-library-list-programmatically

    Hope it helps


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
    Thursday, October 7, 2010 5:52 AM
    Moderator
  • i created 2 webpart by using class library in visual studio 2005 .

     first webpart contain user name ,password,and one button for login .

    second webpart contant user information , emp name ,address,phone no . and one button.

    how to transfer in secong page when we login in first page by using the class library

    Tuesday, February 1, 2011 12:29 PM
  • Hi parur,,

    This is very old thread. You have to create new thread for better response. By the way Try below code. If it does not help much then you may start new thread.


    System.Web.HttpContext.Current.Response.Redirect(" SomePage.aspx");

    Hope it could help


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
    Wednesday, February 2, 2011 4:31 AM
    Moderator