Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
8

8thWonder

@8thWonder
About
Posts
2
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Data bind on Contained Object Properties
    8 8thWonder

    Hello :) I have an object, Car which contains an object, Engine as one of its members. I have a collection of Car objects and I want to bind a drop down list to the collection, displaying a property of the contained Engine object:

    class Car
    {
    public Engine engine; // contains the engine object
    public string manufacturer;
    }

    class Engine
    {
    public int capacity;
    }

    In my code I create a Cars collection: Cars cars = new Cars(); I add my car objects to the collection and bind my collection to a drop doown list:

    myDropDownList.DataSource = cars;
    myDropDownList.DataValueField = "engine.capacity";
    myDropDownList.DataTextField = "engine.capacity";
    myDropDownList.DataBind();

    This doesn't work though because the fields won't accept the syntax I use to specify the contained object's member. On the other hand, this works fine:

    myDropDownList.DataSource = cars;
    myDropDownList.DataValueField = "manufacturer";
    myDropDownList.DataTextField = "manufacturer";
    myDropDownList.DataBind();

    Can anyone tell me how to get my drop down list to bind so that I can display the contained object's member? Thanks :)

    C# tutorial question

  • Desktop/Mobile Serialization
    8 8thWonder

    Hi, I have a class hierarchy of objects representing typical stuff like employees, users, addresses and so on. I've defined the relationships, created a database and now want to add serialization. The top-most class is an abstract one, kind of like CObject I suppose and my objects may exist on a desktop or mobile platform. I started to implement custom serialization but the Compact Framework doesn't support it so now I have to write my own stuff. What I'm looking for is some ideas as to how best to implement serialization for my system. Typically, each object will need to be serialized to/from my database and to/from a web service so I'm guessing I just need to write some methods to serialize to XML and/or to a MemoryStream object. OK, assuming that's the way to implement the actual serialization, how best to define it within my hierarchy? I was thinking of two virtual methods, toXML() and fromXML() defined withing my top-most class and an abstract method called getObjectData() which all descendents *must* implement.

    toXML();
    toMS();
    getObjectData();

    Within toXML() and toMS(), there's a call to getObjectData() which gets the object data ready to be formatted into a MemoryStream object or XML. Each object would also implement a constructor accepting an XML or MemoryStream object but I'm very new to C# so I don't know if there's a way of forcing derived classes to implement these constructors or whether I "should" or not. What do you think? Any help much appreciated including book/article suggestions :)

    C# csharp database xml json help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups