Sharepoint document library file name column in content database?

Hi,
How to get a sharepoint document library file name column in content database?
Thanks
Poomani Sankaran

You're not supposed to develop any solutions accessing the content database directly. It's not supported. Document Library Filename is stored in LeafName column, table: AllDocs.
2.2.6.1 AllDocs Table
This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

Similar Messages

  • Document library: File name with spaces at EOF

    I noticed a strange issue with uploading files with space at end of file (example "ABC  .xlsx"). Such files are allowed to be uploaded for the first time but when the end user (with contribute permission) tries to upload the same file again
    (overwrite) then it uploads the file and goes to the next dialog box where properties for the form is collected (EditForm) and then when user tries to hit save, he gets "Sorry this site is not shared with you" error. The owners (with Full control
    permission) get the error message that the file needs to be renamed. 
    This does not happen with files having proper names. The files are automatically overwritten as expected.
    Is it a SharePoint bug or am I missing something ?

    Hi Prakash,
    When we upload a document which contains spaces at the end of the file name, then SharePoint will trim out the spaces in the Edit Item Form, so the name for this document should be “ABC.xlsx”.
    When we re-upload the document to SharePoint, because of that extra space it sees the filename(ABC  .xlsx) as different to the existing document (ABC.xlsx) so it adds it as a new document.
    And in the edit item form, the space has been trimmed out. Because there is already a document with that filename in the document library, it throws the error.
    So this issue is by design that SharePoint uploads the document first and then edit the properties of the document.
    For more details, please refer to the link below:
    https://discoverlars.wordpress.com/2012/10/27/sharepoint-doesnt-overwrite-a-document-with-the-same-name-but-creates-duplicates/
    Thanks,
    Victoria
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Victoria Xia
    TechNet Community Support

  • Delivery Error when creating Sharepoint Document Library subscription

    Recently we have been having issue with a subscription from a report we have.
    We have a report that has been generated and have a subscription from that report to create a PDF document within sharepoint.
    Recently the subscription stopped working and we have these errors showing:
    A delivery error has occurred. ---> Microsoft.ReportingServices.Diagnostics.Utilities.DeliveryErrorException: A delivery error has occurred. ---> Microsoft.ReportingServices.Diagnostics.Utilities.InvalidExtensionParameter: One of the extension parameters
    is not valid for the following reason: Failed to validate the delivery setting PATH.The specified user USERNAME could not be found.
          Failed to validate the delivery setting PATH.The specified user USERNAME could not be found
    Looking into this, I found a few things but they did not help.
    One thing was to install update 5 for SQL server 2012 R2, but that didn't help.
    Another thing was saying something about there being 2 user accounts, a claims account and a windows user account, but I couldn't figure out how to make it use the correct account.
    I also tried to save it to a Windows File Share, and try to save it to the Sharepoint server side, however that failed stating it couldn't find that path.
    Being that sharepoint is tricky with its file store (is there really a location on the server that files are stored, I cant find it) I could not figure it out.
    I know I can windows explorer to the file location, \\site\shared documents\Folder but if I go to the web servers that host sharepoint I can't find where this path really is.
    Thanks

    Hi,
    According to your post, my understanding is that you want to get error in accessing sharepoint document library files.
    The cause is that the account being used to validate accounts on the production domain had been set to expire the password according to the general domain policy.
    Once the account is set to never expire, the issues will disappear.
    For more information, you can refer to:
    http://kb4sp.wordpress.com/2012/12/05/user-cannot-be-found-shenanigans-one-way-active-directory-trusts-and-sharepoint-2013/
    http://blogs.msdn.com/b/cliffgreen/archive/2013/02/19/sharepoint-2013-the-directory-is-not-a-subdirectory-of-the-root-directory.aspx
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • How to rename the SharePoint Document Library existing file name using Web service

    Hi,
    How to rename the SharePoint Document Library existing file name using SharePoint Web service.
    Is it possible. How could i do it?
    Thanks & Regards
    Poomani Sankaran

    Hi,
    Lists.UpdateListItems Method
    would be helpful for your requirement.
    Here is a blog with code demo for your reference:
    http://blogs.msdn.com/b/knowledgecast/archive/2009/05/20/moss-using-the-list-web-service-to-rename-a-file.aspx
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

  • Some chinese character file name not uploading in SharePoint Document Library?

    Hi
    Some Chinese character pdf file name not uploading in SharePoint Document Library. I am getting following error.
    1. File not found error if i would upload using file browse option in Doc Lib.
    2. Can't read from the source file or disk. if i would tried to copy and paste using "Open with explorer" options.
    File name is "LA(未签署).pdf"
    Note: This file has been converted from "TIFF" to "PDF".
    Thanks & Regards
    Poomani Sankaran

    Hi Poomani,
    For troubleshooting your issue, please let's verify the followings:
    Whether other pdf file which are not converted from "TIFF" and contain Chinese char could be uploaded into the SharePoint Document library.
    Whether other pdf file which are converted from "TIFF" and don't contain Chinese char could be uploaded into the SharePoint Document library.
    Please upload these pdf files into other libraries, compare the result.
    Please check the log file to find more information about this issue. The path of the log file is:
    C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS.
    Best Regards,
    Wendy
    Wendy Li
    TechNet Community Support

  • Download older version of a file from SharePoint Document Library using CSOM and 404 error

    Hi,
    I am trying to download previous versions including Major and Minor versions of documents from SharePoint Online using CSOM. I get 404 error when I try to download the file. I found several posts on various discussion forums where people are getting same
    error but none of those have any solution/answer. Below is one of the threads and sample code I have tried that results in 404 error. If I use the link in browser directly, I am able to download the file. Also I am able to download the current version of file
    using CSOM without any problem, it is only the older versions that give me 404 in CSOM.
    http://qandasys.info/how-to-download-the-historical-file-version-content-using-csom/
    public int GetStreamFromFile(string docid, string lib, string fileurl, ClientContext clientContext, int iuserid, string Version, bool isCurrrent)
    if(!isCurrent)
    List LibraryName = clientContext.Web.Lists.GetByTitle(lib);
    clientContext.Load(LibraryName);
    clientContext.ExecuteQuery();
    CamlQuery camlQuery = new CamlQuery();
    camlQuery.ViewXml = "" + fileurl +
    Microsoft.SharePoint.Client.ListItemCollection collListItem = LibraryName.GetItems(camlQuery);
    clientContext.Load(collListItem, items => items.Include(item => item.Id, item => item["FileLeafRef"], item => item["LinkFilename"],
    item => item["FileRef"], item => item["File_x0020_Size"], item => item["DocIcon"], item => item.File.Versions));
    //clientContext.Load(collListItem);
    clientContext.ExecuteQuery();
    foreach (Microsoft.SharePoint.Client.ListItem oListItem in collListItem)
    //string fileurl1 = (string)oListItem["FileRef"];
    //string filename = (string)oListItem["LinkFilename"];
    foreach (FileVersion version in oListItem.File.Versions)
    if (Version == version.VersionLabel)
    //Added excutequery to get object one more time as per blog
    //http://social.technet.microsoft.com/Forums/de-DE/sharepointdevelopmentprevious/thread/88a05256-8694-4e40-863d-6c77512e079b
    clientContext.ExecuteQuery();
    FileInformation fileInformation = ClientOM.File.OpenBinaryDirect(clientContext,version.Url);
    bytesarr = ReadFully(fileInformation.Stream);
    Darwaish

    Hi,
    According to your description,
    I know you want to get older version of a file from SharePoint Document Library using Client Object Model.
    The following code snippet for your reference:
    public void GetVersions()
    ClientContext clientContext = new ClientContext(“http://SPSite”);
    Web site = clientContext.Web;
    clientContext.Load(site);
    clientContext.ExecuteQuery();
    File file = site.GetFileByServerRelativeUrl(“/Shared Documents/mydocument.doc”);
    clientContext.Load(file);
    clientContext.ExecuteQuery();
    ListItem currentItem = file.ListItemAllFields;
    clientContext.Load(currentItem);
    clientContext.ExecuteQuery();
    FileVersionCollection versions = file.Versions;
    clientContext.Load(versions);
    clientContext.ExecuteQuery();
    if (versions != null)
    foreach(FileVersion _version in versions)
    Console.WriteLine(“Version : {0}”,_version.VersionLabel);
    More information:
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.file.versions.aspx
    Best Regards,
    Dennis Guo

  • Rename a File in a SharePoint document library through Client object model

    Hi,
    How  to Rename a File in a SharePoint document library through Client object model?
    Thanks
    Poomani Sankaran

    Hi,
    According to your description, you want to rename file in the document library using SharePoint Client Object Model.
    Here is a code snippet works well in my environment for your reference:
    static void Main(string[] args)
    string url = "http://sp2013sps/sites/test/";
    ClientContext clientContext = new ClientContext(url);
    Microsoft.SharePoint.Client.List spList = clientContext.Web.Lists.GetByTitle("Documents");
    clientContext.Load(spList);
    clientContext.ExecuteQuery();
    if (spList != null && spList.ItemCount > 0)
    Microsoft.SharePoint.Client.CamlQuery camlQuery = new CamlQuery();
    camlQuery.ViewXml =@"<View> <Query> <Where><Eq><FieldRef Name='LinkFilenameNoMenu' /><Value Type='Computed'>New Microsoft Word Document.docx </Value></Eq></Where> </Query> <ViewFields><FieldRef Name='Title' /></ViewFields> </View>";
    ListItemCollection listItems = spList.GetItems(camlQuery);
    clientContext.Load(listItems);
    clientContext.ExecuteQuery();
    listItems[0]["Title"] = "word.docx";
    listItems[0]["FileLeafRef"] = "word.docx";
    listItems[0].Update();
    clientContext.ExecuteQuery();
    More information about SharePoint Client Object Model:
    http://msdn.microsoft.com/en-us/library/office/ee537247(v=office.14).aspx
    http://www.codeproject.com/Articles/399156/SharePoint-Client-Object-Model-Introduction
    http://www.learningsharepoint.com/2010/07/12/programmatically-upload-document-using-client-object-model-sharepoint-2010/
    Best regards

  • Issue trying to use a Sharepoint document library as a network drive on which a software can create and delete content

    Hi,
    With my colleagues we are using a dictation/transcription software which automatically creates files, moves them from folders to folders and deletes them. Until now, all this was done on a network drive, but the drive will soon be unavailable and
    we will eventually have to use a SharePoint document library instead, and I am currently testing this option.
    I have created a document library (with no versioning and no check out required) and I mapped it as a drive in Windows Explorer to link the SharePoint folders with the dictation software. Everything seems to work fine except
    for one thing: when the dictation software tries to move files from one folder to another, the files are pasted in the destination folder but not deleted from the original folder and an error message pops up saying "delete operation has failed".
    So the softaware is able to automatically create new content in the document library but is unable to automatically delete (I can however delete manually through the software interface).
    Any idea on what is causing this issue and how to solve it?
    Thank you

    Hi,
    According to your description, my understanding is that the documents cannot be deleted in the original folder when using the software with SharePoint library.
    I recommend to verify the things below:
    Which credential did you use to map the document library as network drive?
    If the credential was windows logon, then I recommend to check if the documents can be deleted in the network drive which was connected to SharePoint library directly.
    If the documents can be deleted in the network drive which was connected to SharePoint library, then the issue may be due to the compatibility problem between the software and WebDAV. Then you need to check the issue using third-party software provider.
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Files Uploaded using Mapped Drive (UNC) to SharePoint Document library Putting a copy in Recycle Bin , odd SharePoint Behaviour

    Hello All,
    One of my client reported a strange behaviour.
    Client mapped SharePoint document library to local share(UNC, NetWork Map Drive). Opened MS Word on local machine ,saved it to the share on his local machine. The document is saved successfully to SharePoint document library. But at the same time he can
    see a file with same name in Recycle bin and the size of the document in Recycle bin is <1k.
    Does any one know whether it is expected behaviour, why SharePoint putting this 1k file in Recycle bin?
    I tried the same thing on my Dev Environment for both SharePoint 2010 and 2013, in both environments the behaviour is same as my client experience.
    I have seen in forums some other people also experiencing this odd behaviour, but no one knows why.
    any info on this much appreciated.
    Regards,
    Andrew

    Hi Andrew,
    i tried in my environment for 2010 and 2013. The issue doesn't occur.
    Here is what i did.
    1, Create a new mapped drive(\\servername\DavWWWRoot\Shared Documents) for document library
    2, New a Word doc and input some string, save in the mapped drive.
    3, The doc exists in the document library, but no file in Recycle Bin.
    Did i miss something?
    Regards,
    Tom
    Microsoft Online Community Support
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to
    other community members reading the thread.

  • How to connect SharePoint Document Library with Local file system?

    Hi
    I have a SharePoint Document library and in my local system i have 3TB files. It is very difficult to upload 3TB files in SharePoint.
    I want a file details in SharePoint Document Library but physical file would be in local.
    While click the file in Document library. The document should open from local.
    Anyone help me on it.
    Thanks & Regards
    Poomani Sankaran

    Hi,
    your requirement doesn't work out-of-the-box as all data uploaded to SharePoint needs to be stored in SQL database. Thus in your case 3 TB of fileshare would need to move to SQL.
    In case you don't want to go this way, there are 3rd party vendors who offer Software like AvePoint Connector. Products like these use SQL RBS (Storage Externalization API) so that files remain in your file system but metadata is kept in SharePoint. If you
    need more information on that, please let me know.
    Regards,
    Dennis

  • Save output of powershell script to a SharePoint document library?

    Hi
    I've got the PS script below which scripts out our SQL replication so disaster recovery.  Is there a way to output this to a SharePoint document library so that way we can version control the file to keep multiple copies and it also avoids outputting
    this to a file share.  We would still need to have the files with the .sql extension format which is an allowed file type in our farm.
    Thanks
    #Load command-line parameters - if they exist
    param ([string]$sqlserver, [string]$filename)
    #Reference RMO Assembly
    [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Replication") | out-null
    [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Rmo") | out-null
    function errorhandler([string]$errormsg)
        writetofile ("-- Replication Script Generator run at: " + (date)) $filename 1
        writetofile ("-- [Replication Script ERROR] " + $errormsg) $filename 0
    function writetofile([string]$text, [string]$myfilename, [int]$cr_prefix)
        if ($cr_prefix -eq 1) { "" >> $myfilename }
        $text >> $myfilename
    function initializefile([string]$myfilename)
        "" > $myfilename
    trap {errorhandler($_); Break}
    #Deal with absent parameters
    [string] $hostname=hostname
    if ($sqlserver -eq "") {$sqlserver = read-host -prompt "Please enter the server name or leave blank for Hostname"}
    #if ($filename -eq "")  {$filename = read-host -prompt "Please enter the file name (eg 'c:\ReplicationBackupScript.sql')..."}
    if ($sqlserver -eq "")   {$sqlserver = $hostname}
    if ($filename -eq "")   {$filename = "d:\Rep\CreateReplication-$(get-date -format ddMMyyyy).sql"}
    # Clear file contents
    if (Test-Path  ($filename)) {Clear-Content $filename}
    $repsvr=New-Object "Microsoft.SqlServer.Replication.ReplicationServer" $sqlserver
    initializefile $filename
    # if we don't have any replicated databases then there's no point in carrying on
    if ($repsvr.ReplicationDatabases.Count -eq 0)
        writetofile ("-- Replication Script Generator run at: " + (date)) $filename 0
        writetofile "-- ZERO replicated databases on $sqlserver!!!" $filename 1
        EXIT
    # similarly, if we don't have any publications then there's no point in carrying on
    [int] $Count_Tran_Pub = 0
    [int] $Count_Merge_Pub = 0
    foreach($replicateddatabase in $repsvr.ReplicationDatabases)
            $Count_Tran_Pub = $Count_Tran_Pub + $replicateddatabase.TransPublications.Count
            $Count_Merge_Pub = $Count_Merge_Pub + $replicateddatabase.MergePublications.Count
    if (($Count_Tran_Pub + $Count_Merge_Pub) -eq 0)
        writetofile ("-- Replication Script Generator run at: " + (date)) $filename 0
        writetofile "-- ZERO Publications on $sqlserver!!!" $filename 1
        EXIT
    # if we got this far we know that there are some publications so we'll script them out
    # the $scriptargs controls exactly what the script contains
    # for a full list of the $scriptargs see the end of this script
    $scriptargs = [Microsoft.SqlServer.Replication.scriptoptions]::Creation `
    -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludeEnableReplicationDB `
    -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludeCreateLogreaderAgent `
    -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludePublicationAccesses `
    -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludeArticles `
    -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludePublisherSideSubscriptions `
    -bor  [Microsoft.SqlServer.Replication.scriptoptions]::IncludeSubscriberSideSubscriptions
    writetofile ("-- Replication Script Generator run at: " + (date)) $filename 0
    writetofile "-- PUBLICATIONS ON $sqlserver" $filename 1
    writetofile "-- TRANSACTIONAL PUBLICATIONS ($Count_Tran_Pub)" $filename 1
    foreach($replicateddatabase in $repsvr.ReplicationDatabases)
        if ($replicateddatabase.TransPublications.Count -gt 0)
            foreach($tranpub in $replicateddatabase.TransPublications)
                writetofile "/********************************************************************************" $filename 0
                writetofile ("***** Writing to file script for publication: " + $tranpub.Name) $filename 0
                writetofile "********************************************************************************/" $filename 0
                [string] $myscript=$tranpub.script($scriptargs) 
                writetofile $myscript $filename 0
    writetofile "-- MERGE PUBLICATIONS ($Count_Merge_Pub)" $filename 1
    foreach($replicateddatabase in $repsvr.ReplicationDatabases)
        if ($replicateddatabase.MergePublications.Count -gt 0)
            foreach($mergepub in $replicateddatabase.MergePublications)
                writetofile "/********************************************************************************" $filename 0
                writetofile ("***** Writing to file script for publication: " + $mergepub.Name) $filename 0
                writetofile "********************************************************************************/" $filename 0
                [string] $myscript=$mergepub.script($scriptargs) 
                writetofile $myscript $filename 0

    Check out Using PowerShell to upload a scripts output to SharePoint
    Jason Warren
    @jaspnwarren
    jasonwarren.ca
    habaneroconsulting.com/Insights

  • Attaching Attributes to Image For Loading to SharePoint Document Library

    We currently have a need to create a searchable document library which will consist solely of images. The standard metadata for a file/image won't suffice in this case. We have some custom attributes that will need to be searchable.
    Essentially, we will have a library of receipt images for expense reporting purposes. We get these images from a third party who handles all of our expense reporting. There are two large zipped files we receive: one file contains all the actual expense report
    "data" that was processed that day(amount, date, client, job, etc.) and the second file contains all the receipt images for those expense report items. Each data file contains data for individual expense reports, and each expense report is assigned
    a unique ID. Each line item in an expense report is also assigned a unique ID. Lastly, each receipt image for a line item of a specific expense report is also assigned a unique ID.
    The zipped image file only contains images. There is a main image file - this contains several smaller zipped files. Each of the smaller zipped files contains all receipt images for a specific expense report. Each image file name is comprosed of three parts:
    The expense report identifier, the unique image identifier, and the expense report line item identifier.
    So, to put this all into perspective:
    On Thursday, we received an image file named extract_images_p006320452r3_20140904171423
    This file contained images for the following unique expense reports:
    The compressed file 95FB8C488519427793FC contains the following receipt images:
    The "data" file - as mentioned before - contains the actual info about the expense and image. These include: date of transaction, date approved, vendor, amount. GL code, type, function, client, project, billable or not, and several other attributes.
    All of this information - including the location of the images - is stored in a SQL Server database and then placed in an SSAS cube.
    The images are related back to the underlying data via the expense report id, and line item id.
    What I need to be able to do is to somehow "tag" these images with all their underlying attributes, load then into a SharePoint document library, and make them searchable.
    I have already figured out that I would need to create several SharePoint lists based on the available values in my OLAP cube (essentially a dataset each for clients, vendors, etc.). The part I have no idea how to accomplish is how to tag each image with
    its respective information.
    All the pertinent info is stored in the database tables, just don't know how to attach it to each image.
    Hopefully, this made some kind of sense. If anyone has any idea on how to even remotely accomplish such a thing, your input would be greatly appreciated!
    Thanks in advance!
    A. M. Robinson

    You will have to develop a custom solution to do this. I am assuming you have taken the first steps to define separate document libraries for the expense reports and images along with site columns and contenttypes. You would define the site columns based
    on the data you want to search on and assign these to corresponding contenttypes. So basically a contenttype for expense reports and receipts possibly. You would link the two contenttypes using the expense report id.
    Your custom solution would have to break apart the zip files and upload and index (set site column data) for each file. Then the user could search on the expense report id and get all the files associated with the expense report.
    An alternative could be to use one document library and have all the files uploaded into their own document set (folder).
    Blog | SharePoint Field Notes Dev Tools |
    SPFastDeploy | SPRemoteAPIExplorer

  • SPMenu Field for sharepoint document library

    I have written code where it will show the Sharepoint document library in sp grid view.It
    is showing the grid but i want the default spmenu field for the type icon. please see the attached image. Below is the code of mine
    private void CreateBoundField(string sDataField, string sHeaderText, bool bReadOnly, SPGridView theGridView)
    BoundField field = new BoundField();
    field.DataField = sDataField;
    field.HeaderText = sHeaderText;
    field.HtmlEncode = false;
    field.HeaderStyle.ForeColor = ColorTranslator.FromHtml("#808080");
    field.HeaderStyle.Font.Names = new string[] { "verdana", "arial", "helvetica", "sans-serif" };
    field.ItemStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
    if (sHeaderText.ToLower().Equals("type"))
    field.ItemStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
    field.ItemStyle.Width = Unit.Pixel(35);
    field.HeaderStyle.Width = Unit.Pixel(35);
    field.ReadOnly = bReadOnly;
    if (!bReadOnly)
    field.SortExpression = sDataField;
    field.Visible = true;
    theGridView.Columns.Add(field);
    SPGridView gv = new SPGridView();
    gv.ID = "gv";
    gv.EmptyDataText = "No items found!";
    gv.AllowSorting = true;
    gv.AllowFiltering = true;
    gv.AutoGenerateColumns = false;
    gv.EnableSortingAndPagingCallbacks = true;
    CreateBoundField("Type", "Type", false, gv);
    CreateBoundField("Title", "Title", false, gv);
    CreateBoundField("Date", "Date", false, gv);
    CreateBoundField("ProcessTask", "ProcessTask", false, gv);
    DataTable dt = new DataTable();
    SPWeb web = SPContext.Current.Web;
    SPListItemCollection items = web.Lists["Shared Documents"].Items;
    dt.Columns.Add("Type");
    dt.Columns.Add("Title");
    dt.Columns.Add("Date");
    dt.Columns.Add("ProcessTask");
    foreach (SPListItem item in items)
    DataRow dr = dt.NewRow();
    string value = item["ProcessTask"].ToString();
    value = value.Substring(value.LastIndexOf(";#") + 2);
    string docicon = SPUtility.ConcatUrls("/_layouts/images",
    SPUtility.MapToIcon(item.Web, SPUtility.ConcatUrls(item.Web.Url, item.Url), "", IconSize.Size16));
    dr["Type"] = string.Format("<img src='{0}' />", docicon);
    dr["Title"] = item.Title;
    dr["Date"] = item["Created"].ToString().Split(' ')[0];
    dr["ProcessTask"] = value;
    dt.Rows.Add(dr);
    gv.DataSource = dt;
    gv.DataBind();
    this.Controls.Add(gv);
    SPListItemCollection _GridCollection = SPContext.Current.Web.Lists["Shared Documents"].Items;
    DataTable _MyDatabale = _GridCollection.GetDataTable();
    gvdetails.DataSource = _MyDatabale;
    gvdetails.DataBind();
    I want the default menu pop up like the below attached image. Can any one help me to
    modify the above code and get me the attached out put.
    Thanks,
    Sandy.

    Hi,
    According to your post, my understanding is that you wanted to show the SharePoint document library in GridView.
    You need to get hold of the SPFile object, which is a property of a ListItem item, and get the ServerRelativeUrl property. Then you need to add code to an <a> tag .
    Here is a similar thread for your reference:
    http://sharepoint.stackexchange.com/questions/88139/code-download-file-from-doc-icon-image-in-sharepoint-2010
    More information:
    Bind SharePoint 2010 Document Library to GridView:
    http://sppractices.blogspot.com/2013/03/bind-sharepoint-2010-document-library.html
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Error while programmatically adding a document to SharePoint document library

    Hello everyone,
    I have created a custom content type and modified the document template to use the quick parts inside the template.
    I have a document library which uses the custom content type. 
    I have a button inside a custom application page(created using visual studio). On click of this button I want to create a new document inside the document library using the custom content type and update other columns in the content type. I am able to create
    the document, but I get the below error when I open the document.
    public static void UpdateAndCreateFile(SPWeb web)
    try
    web.AllowUnsafeUpdates = true;
    string sList = "My Document Library";
    string sContentType = "My Custom Document";
    SPList list = web.Lists[sList];
    // this always uses root folder
    SPFolder folder = web.Folders[sList];
    SPFileCollection fcol = folder.Files;
    // find the template url and open
    string sTemplate =
    list.ContentTypes[sContentType].DocumentTemplateUrl;
    SPFile spf = web.GetFile(sTemplate);
    byte[] binFile = spf.OpenBinary();
    // Url for file to be created
    string destFile = fcol.Folder.Url + "/" + "test2.docx";
    // create the document and get SPFile/SPItem for
    // new document
    SPFile addedFile = fcol.Add(destFile, binFile, true);
    SPItem newItem = addedFile.Item;
    newItem["ContentType"] = sContentType;
    newItem.Update();
    addedFile.Update();
    web.AllowUnsafeUpdates = false;
    catch (Exception ex)
    // handle exception here
    The above code gives the same issue when I use the 'Document' content type instead of the "My Custom Document" content type. 
    The document looks/opens fine when I create it from the browser.
    Please let me know if you have any suggestions. Thanks.

    I could not figure out a proper solution, but here is what I did to get around the issue.
    I created a document using the document template and saved it to the library(same doc library) and named it as Sample.docx
    In my code, every time I had to create a document, I would just copy the Sample.docx file to the library, but make sure I rename the file when I copy it.
    Then I can use the url of the file I saved through my code and get the list item and update the other properties/columns of the content type
    Below is the code to use an existing file and create a new file
    public static void UpdateAndCreateFile(SPWeb web)
    try
    web.AllowUnsafeUpdates = true;
    string sList = "My Documents";
    SPList list = web.Lists[sList];
    // this always uses root folder
    SPFolder folder = web.Folders[sList];
    SPFileCollection fcol = folder.Files;
    SPFile file = fcol[sList + "/Sample.docx"] ;
    file.CopyTo(sList + "/" + "test1.docx", true);
    web.AllowUnsafeUpdates = false;
    catch (Exception ex)
    Thanks.

  • Linking a programmatically created folder in SharePoint Document Library.

    I have created folders within a document library using InfoPath & C#. To that folder I uploaded several documents using several file attachment controls within the same InfoPath Form using the code behind the form.  Now I want to create an Hyperlink
    to each folder in another document folder's column that has the relationship with the previously created folder.
    When I googled I saw there are lot of articles to create Folders ,uploading documents to folders in a SharePoint Library but I cannot understand how to create a hyperlink in a SharePoint Document Library field column.
    Could someone help me to solve this matter?
    Thanks,
    Regards,
    Chiranthaka

    Why don’t you create a hyperlink column to store the hyperlink value, or you can use a lookup column to lookup the related folder item?
    Qiao Wei
    TechNet Community Support

Maybe you are looking for