PC Review


Reply
Thread Tools Rate Thread

complex object databinding

 
 
Random
Guest
Posts: n/a
 
      5th Feb 2007
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?


 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
Guest
Posts: n/a
 
      6th Feb 2007
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
--
Milosz


"Random" wrote:

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

 
Reply With Quote
 
sloan
Guest
Posts: n/a
 
      6th Feb 2007
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?
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Complex databinding Craig Buchanan Microsoft ASP .NET 1 27th May 2008 07:20 AM
WPF: Complex Databinding J.Marsch Microsoft C# .NET 0 15th Mar 2008 06:04 PM
Complex databinding with ASP Listbox Ray Valenti Microsoft ASP .NET 1 1st Dec 2003 03:54 PM
Complex databinding with ASP Listbox Ray Valenti Microsoft ADO .NET 1 1st Dec 2003 03:54 PM
Complex databinding Tim Tafflinger Microsoft Dot NET Compact Framework 6 25th Sep 2003 10:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:16 PM.