.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Show folder content in a ListBox

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :WPF
Hi. I am close to going crazy here :) I have a small app and I want people to be able to open some files from within it. All I want is a small control that shows me the content of a specific folder on the HDD. My current approach includes a ListBox which should be filled with the documents of that folder. However I have (even after hours of googling and binging^^) absolutely no idea how to get them in there. I hoped that you could databind your ListBox to the file system, but this does not seem to be possible. Do I have to fill it via c# code? If so, how?   Any help would be greatly appreciated.  

View Complete Post

More Related Resource Links

Button inside ListBox does't show content

Hi,   We've made a ControlTemplate that defines a rounded border and some animation on mouseover that is default for our buttons, them we put a ContentPresenter inside this Button, on a layer above that default background so we can change the content of the button depending on where we`re using it. Them, we created a Style (DefaultButtonStyle) that would set the template to our template. And finally, for each diferent button we created a Style (BasedOn the DefaultButtonStyle) that would set a ToolTip and the Content, the Content is a Rectangle with the fill property set using DynamicResource to a DrawingBrush with the image we want for that button. Now, a ListBox uses a DataTemplate that has a button with one of the styles we`ve defined earlier. (Some like a print button for each row on the table).   The big problem is: When we run the program it only shows the image on the last line of the ListBox, all the other lines show the buttons without the Rectangle. Trying to see if we could reproduce the error we`ve noticed that even if its not on a ListBox, if we open 2 instances of the same screen, the button would not show. Is there any limitations on using styles and templates for this? It only bug the Content we added on the Styles with BasedOn the DefaultButtonStyle, the other properties like animations and background (defined in the defaul

Adding New Custom Folder Content Type doesn't show up on the Document Library New Menu


I been trying to add new custom folder content type to the document library programatically in my sandbox environment and it does show up on the document library. But, when I move same code to the almost similar configured SP2010 environment, adding new folder content type to the document library doesn't show up on the document library's new menu.

Here is the code? Since this code works fine in my sandbox environment, is there any other settings I should check on the server environment which would cause hiding content type on new menu of document library.

  class Program
    static void Main(string[] args)
      SPSite spSite = new SPSite("http://sp2010vm");
      foreach (SPWeb spWeb in spSite.AllWebs)
        spWeb.AllowUnsafeUpdates = true;

        //For each site, cycle through lists
        bool isDocLibraryExists = false;
	      foreach(SPList spList in spWeb.Lists)
          if(spList.Title == "Classified Documents")
             isDocLibraryExists = true; 
        if(isDocLibraryExists == true)
          //Create new doc library
          SPList splist = spWeb.Lists["Classified Documents"];

          //Create Content Type
          SPContentType documentContentType = spWeb.AvailableContentTypes["Classified Documents Folder"

Content Query Web Part (CQWP) fails to show picture items from a document/picture library in an anon

I have a Picture Library and am trying to use the CQWP to display a list of items in the library.  The web part shows the items fine in authenticated mode, but it fails to show the items to anonymous users. The error log message is: Error while executing web part: System.NullReferenceException: Object reference not set to an instance of an object.     at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart.SetDocumentIconUrlAndOnClickString(SPWeb web, DataRow row, String strDefaultItemOpen, Boolean fSetDocIcon, Boolean fSetOnClick, String fileRefColumnRef, String progIdColumnRef, String fsobjTypeColumnRef, String permMaskColumnRef)     at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart.PreProcessForDocumentIconAndOnClickAttribute()     at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart.AddContentQueryData()     at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart.GetXPathNavigator(String viewPath)     at Microsoft.SharePoint.WebPartPages.DataFormWebPart.PrepareAndPerformTransform(Boolean bDeferExecuteTransform) I'm running SP 2010.  I've tried various scenarios including: 1. Using the default publishing template. 2. Using the blank site template with publishing and lock down features enabled. 3. Us

Folder inside the List shows Access Denied when try to open using Manage Content Structure

Hi All, We are facing this issue in one of our site, when accessing the folder from Manage content structure. Folder is inside a list which uses a folder content type. When we try to open this folder use manage content and structure it throws access denied. any idea how we can check this as we the permissions are properly inherited and all the folders are checked in . Please update what else we can check.   Thanks, Jasjeet SIngh

ModalPopupExtender allows content panel to show, but everything is disabled

I have a user control (ascx) vs 2010 that contains a modalpopup extender thats popup control is an asp:panel.  In that Panel I have an update panel and a contenttemplate inside the upd panel.  It is a pretty simple example of its use, in that I have list box allowing the users to create a new row in a table.  However, when I click targetcontrol, the background changes to the expended modal background, but instead of being able to use the listbox, everything in the content panel is the same as the background and none of the controls on the panel are enabled.  In other words, the entire page is loaded dimgray, including the updatearea. Not sure what is going on here, but any help would be appreciated.

Sharepoint Content Type - Folder

Hi Everyone,

 Please help me urgent..!

 I have the following content types

  ShareDoc Document     
  Program or Project Folder    
  Secure Folder 

I am creating nested folder in sharepoint document library in my project.
I created one folder name is "Test" and content type "Program or Project".If i create a subFolder , the content type of subFolder is "Program or Project".Becuase it is taking default parent content type.But i want to change the content type to "Folder".Please give me solution to reslove it.

Shiva Reddy.P

How to show the content of two tables in one report?


Hi there,

I am working with reporting services for the first time and I have a very basic question, but can't find a solution for it anywhere. I use Visual Studio 2008 and SQL Server 2005.

Here is the problem:

I have two SQL data tables, one consisting of general data about a person (name, age,..) and one containing their employment data (joining date, salary, ...). I now want to show both tables for one particular person in one report such that the general data as well as the employment data each have their own section, such as


Name: Thomas Mueller

Age: 27

Folder Content Type in Document Set



Is it possible to include a Folder Content Type as the  default content , when a new instance of Document Set content type is created ? If so, how can we do this?


View content of a specific folder in customized view


I would like to create a customized view (edit current view] that only shows the content of one specific sub folder of a document library. So far I have used meta data to show only specific content in a view, but I am wondering whether there is any easier solution, such as "filename" begins with ../../.../foldername

Content Query Webpart to show edit item link field in SPS2010


I have a Content Query Webpart in SharePoint 2010 that I would like to surface Documents grouped by content type. I wish to show the edit form or view Properties link as part of the fields shown in the results. When the User clicks on this link, it should take him to the edit form or view Properties page for the document.

Any ideas?

WPF: how can ListBox display three columns: first and thrid column width base on the longest content


We try to use ListBox to display three columns: so the first and last column width will depend on the longest content in that column to decide and second column take the rest of space as its width.

How can we use ListBox to achive that?

should we try with the ListView? thx!

Listformwebpart misbehaving for folder-based content types


I created a number of folder content types, adding several metadata fields to the default content type.  I then created multiple document libraries that use those content types (as well as custom document content types).  I did not customize any of the forms.  All was well.  I then saved my site as a template, and created some new sites from that template.

Now weird stuff started to happen.  For one of my content types, the "new" form lost the custom metadata fields.  When making a new folder of this type, the form looks the same as the new form for a vanilla folder.  But once it is created, both the "edit" and "display" forms displayed all the fields correctly.

For another content type, I got the opposite behavior.  The "new" form shows all the custom metadata fields, but the "edit" form only shows the vanilla folder fields.  The "Display" form is fine.  I can even pull up the Display form, verify that all the expected fields are there, click the Edit button, and watch the form shrink to the reduced-field size.

It is as if the listformwebpart is selectively failing to acknowledge that the content type it is dealing with is anything other than Folder.

To summarize:

  • The original site I built works fine, but a

How to Link to a Document content type but linking to a Folder

I have implemented the known "Link to a Document" content type to a Document Library (referenced below).  This works fine to documents, but we need to also enter UNC paths to Folders like file://\\servername\sharename\foldername

We can NOT create shortcuts to these folders, which is a work around someone else published.

If you add the Hyperlink field it allows you to enter a UNC path to externally stored folder just fine. So there must be some way to make this Link to a Document content type also open UNC Folders accurately.


Code Snippet
function HasValidUrlPrefix_Override(url)
            var urlLower=url.toLowerCase();
            if (-1==urlLower.search("^http://") &&
            -1==urlLower.search("^https://") && -1==urlLower.search("^file://"))
            return false;

Is there a way to show xHTML content in a SQL Server Reporting services?

Is there a way to show HTML content (in a table column) in a SQL Server Reporting services ?

How to get Reusable Content to show up in subsite?


I have Reusable Content List in my root site collection that contains some custom image layouts and also some custom sub-site navigation that I would like to include in all pages under a particular Subsite.  I created a page template that included the resuable content just fine.  I can also create a page using this template at teh root level without issue, however; I cannot create a page using this template at a subsite level below the root site collection.

Can someone confirm if this is possible or not.  The error I get is:

List does not exist

The page you selected contains a list that does not exist.  It may have been deleted by another user.

Thank you for your thoughts and comments.


Not all content type columns show up in DisplayForm.aspx


I have a list that when displaying the DisplayForm.asp does not show all the columns of my content type.  I double checked that the column Status was Optional( not Hidden), so I don't understand why they don't show up.  Can anyone advise please?  For site visitors that only have View rights, DisplayForm is the logical way to view the list item, so they need to see all columns.


Edit - I was able to get the missing elements to display by switching the column to Required rather than Optional.  While I think this will work in my case because the new items are coming from a webservice that provides this data, it doesn't seem like this should be required.  I thought by default ALL columns/fields displayed on the forms UNLESS marked as hidden.

There are no mistakes; every result tells you something of value about what your are trying to accomplish.

Uploading Office 2003 files are set to Folder Content Type


Hi All,

Been pulling my hair out trying to figure this one and am hoping that you are able to help.

Have been putting together a new SP2010 Standard environment and have gone as far as creating some sites, sub sites and generating Content Types and assigning to Doc Libraries etc.

The problem comes when we are attempting to upload existing Office 2003 files, namely Word .doc files, and only happens on specific libraries, this is not across the board.

 When we upload an existing 2003 file to the affected library, we are not able to set any meta data to the file as SharePoint registers the Content Type as a Folder as seen in the properties of the file:


Description: cid:image001.png@01CB5A4C.D9F0EA90


However, if we upload a pre-existing Office 2010 .docx, we get the full array of Meta Data and the correct Content Type has been assigned.


Do any wonderful people have any clues as to what could be causing this?


Thanks in advance

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend