Binding a single object to a control

Discussion in 'ASP .Net Building Controls' started by paul.hester@gmail.com, Nov 1, 2006.

  1. Guest

    Hi all,

    This probably sounds like a stupid question, but what is generally the
    recommended way to display a business object in the aspx file for an
    object fetched in the code behind file?

    Normally I've been fetching the object in the code behind and exposing
    the object's properties that I need as Page properties, but I'd like to
    know if there's a better way to do it - e.g. is there a good way of
    binding an object (i.e. not a data set/collection etc.) to a control
    and displaying the properties that way.

    Thanks in advance,

    Paul
     
    , Nov 1, 2006
    #1
    1. Advertising

  2. You can use FormView or DetailsView controls.

    http://msdn2.microsoft.com/en-us/library/fyf1dk77.aspx
    http://msdn2.microsoft.com/en-us/library/s3w1w7t4.aspx

    There is a good Design-Time support to help you attach the properties
    to the controls so you can display them.

    Brennan Stehling
    http://brennan.offwhite.net/blog/

    wrote:
    > Hi all,
    >
    > This probably sounds like a stupid question, but what is generally the
    > recommended way to display a business object in the aspx file for an
    > object fetched in the code behind file?
    >
    > Normally I've been fetching the object in the code behind and exposing
    > the object's properties that I need as Page properties, but I'd like to
    > know if there's a better way to do it - e.g. is there a good way of
    > binding an object (i.e. not a data set/collection etc.) to a control
    > and displaying the properties that way.
    >
    > Thanks in advance,
    >
    > Paul
     
    Brennan Stehling, Nov 2, 2006
    #2
    1. Advertising

  3. kferron Guest

    If i understand you correctly, you're actually trying to show all of
    the values of a business object in some display?

    Lets say you have a Customer, are you looking for a way to have a
    control that binds directly to Customer?

    In my opinion, even though it seems superfluous, one of the easy ways
    to do this is make a Collection<Customer> with just the single customer
    reference in it. Then Databind the collection to DetailsView with
    AutoGenerateColumns=true.

    This gives you a spit out of the current object, and is by no means
    glamorous, but does allow for a 'propertygrid' feel directly on your
    custom type.

    hope this helps.


    On Oct 31, 9:25 pm, wrote:
    > Hi all,
    >
    > This probably sounds like a stupid question, but what is generally the
    > recommended way to display a business object in the aspx file for an
    > object fetched in the code behind file?
    >
    > Normally I've been fetching the object in the code behind and exposing
    > the object's properties that I need as Page properties, but I'd like to
    > know if there's a better way to do it - e.g. is there a good way of
    > binding an object (i.e. not a data set/collection etc.) to a control
    > and displaying the properties that way.
    >
    > Thanks in advance,
    >
    > Paul
     
    kferron, Nov 15, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Randall Parker
    Replies:
    1
    Views:
    608
    S. Justin Gengo
    Dec 12, 2005
  2. Chris
    Replies:
    1
    Views:
    13,652
    Oisin
    Mar 24, 2006
  3. chris brat
    Replies:
    1
    Views:
    644
    chris brat
    May 10, 2006
  4. Paul
    Replies:
    0
    Views:
    270
  5. Binding a single object to a control

    , Nov 1, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    89
Loading...

Share This Page