Look at this code. Sorry I only have vb.net handy:
Take a look here, it might help:
CurrentPublisher.PublisherName is a nested property.
Dim titleIdBinding As Binding = _
txtTitleId.DataBindings.Add("Text", Me.m_model, "TitleId")
'Improved in .NET 2.0 //
http://msdn2.microsoft.com/library/y0h25we8(en-us,vs.80).aspx
'titleIdBinding.NullValue = "Type a TitleID Here"
'a text box
Me.txtTitleId.DataBindings.Add(New Binding("Text", Me.m_model,
"TitleId"))
''a text box
Me.txtPublisher.DataBindings.Add(New Binding("Text", Me.m_model,
"CurrentPublisher.PublisherName"))
'a date control
Me.dtpPubDate.DataBindings.Add(New Binding("Value", Me.m_model,
"PublishedDate"))
'a text box
Me.txtPubDate.DataBindings.Add(New Binding("Text", Me.m_model,
"PublishedDate"))
class Publisher
--------------------
string PublisherName
class Title
-------------
string TitleId
strng Title
Publisher CurrentPublisher
"Random" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have a very full and complex object that contains objects as properties
> and a few collections, and I'm working to databind it to a page. A lot of
> textbox and dropdowns on the page, a few grids. I'll need to be able to
> easily read back edits on a postback, so I'm looking at different
scenarios
> that people have had to implement aside from the simple objectdatasource
and
> gridview examples.
>
> Some suggestions I've seen involve using the ITypedList, IEditableObject,
or
> IBindingList. Still, most of the examples I see apply to special needs of
> binding to collections. Does anyone here have any recommendations as far
as
> base classes I should have my object inherit from, or the right
interface(s)
> I need to use for my scenario?
>
>
|