Binding a single object to a control

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default Binding a single object to a control

    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

    paul.hester@gmail.com Guest

  2. Similar Questions and Discussions

    1. single row binding is not working in Datagrid
      Hi, I am trying to bind single row to datagrid, using following code . it is not displaying row at all, but same code works if i add another item...
    2. Binding DirectoryEntry to AD object via GUID
      I notice in the help files a reference that implies that you can create a DirectoryEntry object that binds directly to an active directory object...
    3. binding user control to Repeater web control
      Hi, I have designed a user control which exposes properties for data binding in the containing web page, and I want to use the Repeater web...
    4. Binding custom object to a listbox
      I have a class I wish to enter into a listbox public Class AnswerListItem Public Answer As String Public Order As integer End Class Here...
    5. Binding IEnumerable derived object
      This is more of a why question then how. When I bind a key-value collection to a control, I know to set DataTextField and DataValueField to key...
  3. #2

    Default Re: Binding a single object to a control

    You can use FormView or DetailsView controls.

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

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

    Brennan Stehling
    [url]http://brennan.offwhite.net/blog/[/url]

    [email]paul.hester@gmail.com[/email] 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 Guest

  4. #3

    Default Re: Binding a single object to a control

    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, paul.hes...@gmail.com 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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139