complex object databinding

R

Random

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?
 
G

Guest

Howdy,

Have in mind complex expression evaluation works fine for Eval() method
(i.e. Eval("MyBusinessObject.Property.AnotherProperty")), but don't expect it
works when binding values back to source via Bind() method: <asp:TextBind
runat="server" Text='<%# ("MyBusinessObject.Property.AnotherProperty") %>'/>
is not going to work. So evenif you implement all the interfaces,
objectdatasource, gridview or any data bound control may not understand
complex Bind() expression and you'll have to code it manually.

hope this helps
 
S

sloan

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top