[E2007] [PS 8.1.338] [C#]: Use powershell results as a datasource RRS feed

  • Question

  • I have some existing code that takes a Collection of PSObject and simply assigns it to the DataSource property of a normal ListView on an ASP.Net page.

    Collection<PSObject> retval = ps.RunCmd(cmd);
    ListView1.DataSource = retval;

    This has been working fine for some time on a .Net 3.5 site created using VS 2008. I recently upgraded a copy to .Net 4.0 using VS 2010 and now I am getting an error.

    DataBinding: 'System.Management.Automation.PSObject' does not contain a property with the name 'eventid'.

    It appears there is nothing wrong with the PSObject collection. I see valid items and eventid is a valid property name. With some extra testing it can seem to find any of the properties that are present in the collection.

    Am I not assigning this to the DataSource properly?

    Thank you

    Friday, March 11, 2011 10:54 PM

All replies