Long posty

    Date: 12/27/05 (C Sharp)    Keywords: security, microsoft

    This is a long post about one problem I have with Microsoft Report Viewer reports for .NET 2.0. Please don't skip it :)

    ok, I have a simple windows form with report viewer control placed on it. The datasource for my reports is an object described in a class. Most of the fields are pretty simple like:

    public string ObjectOperationType
      {
       get
       {
        return ent.Offer.OfferType.ToString();
       }
      }

    where "ent" is a business object the application uses.

    Some fields, though, are bit more complex and return List<> of things, like:

    public List ObjectCloseLocations()
      {
       List items = new List();
       foreach (DirectoryEntry de in ent.Attributes[31].AvailableItemsList)
       {
        if (((ListDirectoryEntries)ent.Attributes[31]).Contains(de))
        {
         items.Add(new CloseLocations(de.Term, true));
        }
        else
        {
         items.Add(new CloseLocations(de.Term, false));
        }
       }
       return items;
      }

    The CloseLocations type is a class with two public fields (Key and Value) that are filled by my method and then passed into the report as a list and the report will show the list in a table quite happily.

    It all works fine, as long as you don't have to include the ListsTypes() on your reports.

    Originally, the code to get the proper BindingSource running looked like this:


    ViewObject MyData = new ViewObject(vid, HidePD);
       this.ViewObjectBindingSource.DataSource = MyData;
       this.comfortAndSecurityBindingSource.DataSource = MyData.ObjectComfortAndSecurity();
       this.closeLocationsBindingSource.DataSource = MyData.ObjectCloseLocations();
       this.propPhotoBindingSource.DataSource = MyData.PropertyImages();
       reportViewer1.RefreshReport();

    Now, when I pass List to my primary BindingSource, the other binding sources have to be List<> or List types.

    I tried this:

    List myData = new List();
    ... fill the list...
    List> comfort = new List>();
    foreach(ViewObject vo in mydata)
    {
    comfort.Add(vo.Comfort());
    }
    this.comfortAndSecurityBindingSource.DataSource = comfort();

    the problem now is that the comfort List<> is not "bount" to it's parent object that shall be getting data from it. How can I fix this?

    Has anyone dealed with this?

    Source: http://community.livejournal.com/csharp/44980.html

« Drawing a line on a form. || A system call that should... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home