Data binding to an object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon Verona

    #1

    Data binding to an object

    I don't know if I'm missing something... but.. is it possible to databind a
    text box to a read/write property of an object at design time?

    I see lots of examples to binding to a dataadapter etc, but if I have a
    class which represents a business object can I bind directly to the
    properties of the class?

    Regards
    Simon

    --
    =============== =============== ==
    Simon Verona
    Dealer Management Service Ltd
    Stewart House
    Centurion Business Park
    Julian Way
    Sheffield
    S9 1GD

    Tel: 0870 080 2300
    Fax: 0870 735 0011


  • Steven Nagy

    #2
    Re: Data binding to an object

    Yes but only in VS2005. Older versions I don't think its possible...
    There's new object data providers in 2005 although I haven't actually
    started using 2005 yet so not sure how, where, etc.

    Simon Verona wrote:
    I don't know if I'm missing something... but.. is it possible to databind a
    text box to a read/write property of an object at design time?

    Comment

    • Simon Verona

      #3
      Re: Data binding to an object

      Ok thanks.. I'm still on VS2003.. It seems like an interesting omission.

      As an aside, if I was to try and implement this by inheriting the textbox
      class (and perhaps some of the others) and have two additional properties
      called "object name" and "property name", could I then access the property
      through reflection?

      Would there be a performance penalty to pay to do this?

      Anybody give me a head start in terms of coding... ?

      Thanks in advance
      Simon
      --
      =============== =============== ==
      Simon Verona
      Dealer Management Service Ltd
      Stewart House
      Centurion Business Park
      Julian Way
      Sheffield
      S9 1GD

      Tel: 0870 080 2300
      Fax: 0870 735 0011

      "Steven Nagy" <learndotnet@ho tmail.comwrote in message
      news:1152156267 .394770.70390@m 79g2000cwm.goog legroups.com...
      Yes but only in VS2005. Older versions I don't think its possible...
      There's new object data providers in 2005 although I haven't actually
      started using 2005 yet so not sure how, where, etc.
      >
      Simon Verona wrote:
      >I don't know if I'm missing something... but.. is it possible to databind
      >a
      >text box to a read/write property of an object at design time?
      >

      Comment

      • Steven Nagy

        #4
        Re: Data binding to an object

        That would work. I wouldn't be able to comment on the performance of
        reflection. I use it but have never clocked it. Wouldn't be too bad I
        suppose because you aren't talking about massive amounts of objects and
        form components right? Check out the System.Type class and all its
        methods for getting lists of fields and methods and so on to get
        started with reflection.

        But there might be an easier way.

        Perhaps you only need your object to implement an interface to
        databind. I haven't investigated this specifically, but what is the
        distinct attributes of the data table and data row that allow them to
        be data bound?
        Could your object inherit from these instead? Or is changing the object
        not possible?

        I assume you have checked out the BindingManager and all its uses?

        Steven

        Comment

        • Simon Verona

          #5
          Re: Data binding to an object

          Don't assume anything!! ;)

          I've not checked out anything yet.

          I'm looking for the longer term... At the moment, some of my business logic
          is exposed in my user interface, mainly because because I need to bind to
          the raw data.

          I want to be able to remove all the business logic into a seperate set of
          classes, and then bind to the various properties instead - this will allow
          me to neaten my code up and remove lots of the business logic out of my UI
          (I've already done some of this by writing classes that partially handle the
          logic).

          I'm planning to migrate to VS2005 towards the end of the year, so I may just
          wait till then before I do this.

          Regards
          Simon

          --
          =============== =============== ==
          Simon Verona
          Dealer Management Service Ltd
          Stewart House
          Centurion Business Park
          Julian Way
          Sheffield
          S9 1GD

          Tel: 0870 080 2300
          Fax: 0870 735 0011

          "Steven Nagy" <learndotnet@ho tmail.comwrote in message
          news:1152225783 .311467.250700@ j8g2000cwa.goog legroups.com...
          That would work. I wouldn't be able to comment on the performance of
          reflection. I use it but have never clocked it. Wouldn't be too bad I
          suppose because you aren't talking about massive amounts of objects and
          form components right? Check out the System.Type class and all its
          methods for getting lists of fields and methods and so on to get
          started with reflection.
          >
          But there might be an easier way.
          >
          Perhaps you only need your object to implement an interface to
          databind. I haven't investigated this specifically, but what is the
          distinct attributes of the data table and data row that allow them to
          be data bound?
          Could your object inherit from these instead? Or is changing the object
          not possible?
          >
          I assume you have checked out the BindingManager and all its uses?
          >
          Steven
          >

          Comment

          Working...