How to Create Document Library in SharePoint site:
In my previous article I'm explaining how to create SharePoint site and how to add Users to that and how to give permissions. Now I'm trying to explain how to Add Document Library to SharePoint site and How to add custom columns to that and how to sort the columns and how to sort the data based on filtering.
What is Document Library:
A place for Sorting documents or other files that you want to share. Document libraries allow folders, versioning, and check out.
Follow the below steps to achieve this:
1) Create a Document Library go through site actions and choose More options then one pop up window will appear.
2) Then choose a Library and then choose Document Library and give a name for that and then click on create button.
3) Now the Document Library with the name Document is created successfully.
4) by default columns for Document Library is Type, Name, Modified, Modified By.
5) Now if you want to add some custom columns for this Document ( Document Library) then go through that Document Library and then choose Library in top navigation bar.
6) Then choose Create Columns, one pop up window will appear for creating columns. Give a name for that as "Doc" and Description also. The maximum characters for creating column name is 255 characters only. You can't give more than 255 characters while creating column name. and then give OK button now column is created successfully.
7) Now, column is created at last position. We need to modify the view of this then go through Modify View behind the Created column then it will redirect to new page then give a preference for this and click on Ok button. Now I give preference for columns order is Type, Name, Doc, Updated, Updated By.
8) If we choose the Doc Preference 3 then automatically updated preference will change from 3 to 4 and Updated Preference will changed from 4 to 5.
9) After changed the columns view the view looks like below.
10) Now ,we are successfully created Document Library and columns also. Now, we are able to Store the Data into that Document Library.
11) If you want to sort the latest data as top then go through that column and then right click of that then choose Z on Top for Display the data in Descending order purpose.
12) If data reaches certain limit then we are unable to fetch the information immediately for that purpose we are using sorting and filtering by columns wise data. Then choose filter option to filter purpose.
How to Store the Data from .NET Application to Document Library:
We can store the data in Document Library in the form of files. Here I give the examples to store it in.
protected void btnUpload_OnClick(object sender, EventArgs e)
SPCurrentSite objCurrentSite = new SPCurrentSite();
SPDocumentLibrary objFile = new SPDocumentLibrary();
Hashtable taskHash = new Hashtable();
taskHash["Doc"] = lblDoc.Text;
string FileName = flUpload.FileName;
string FileType = FileName.Substring(FileName.IndexOf('.') + 1);
byte File = flUpload.FileBytes;
objFile.AddLibraryItemAttachment(objCurrentSite.SiteURL, objCurrentSite.WebSiteName, "Document", File, lblDoc.Text + "-" + lblRev.Text + "." + FileType, taskHash);
In the above example AddLibraryItemAttachment will be used to Add the items to DocumentLibrary.
public Guid AddLibraryItemAttachment(string SiteURL, string WebURL, string ListName, byte Attachment, string AttachmentName, Hashtable dtList);
How to Get back the stored files from SharePoint to .NET Application:
For fetch the files from document library to our dotnet application then we refer below sample code for fetching the data.
string Query = "<Where>" + "<Eq><FieldRef Name='Doc'/><Value Type='Text'>" + lblDoc.Text + "</Value></Eq>" + "</Where>";
DataTable dtDoc = objFile.ListContent(objCurrentSite.SiteURL, objCurrentSite.WebSiteName, "Document", Query);
public DataTable ListContent(string SiteURL, string WebURL, string ListName, string Query);
Hope this article will give you brief description out of creating Document Library and store the files in that and fetch that stored files from that. Hope all are enjoying with this..
No responses found. Be the first to comment...