T
TheGG
Control.DataBind() performs databinding for the current control and all child controls. How would I (within a Control subclass) _just_ perform databinding for the current control, and not the children?
child controls. How would I (within a Control subclass) _just_ performTheGG said:Control.DataBind() performs databinding for the current control and all
Teemu Keiski said:Hi,
Control (System.Web.UI.Control) itself does following in DataBind method.
1. Call base class's OnDataBinding
2. Checks if Controls collection is empty (it has child controls), if it
doesn't e.g it is empty then it just returns from the method
3. Sets Controls collection to be read-only
4. Iterates through Controls and calls dataBind for them one by one
5. Releases the Controls collection
And DataBind method is overridable/virtual so in a simple way you could just
override it and write the similar logic but do not loop through child
controls. That is...just call base class's OnDataBinding and return from the
method. Certainly you need also to do/specify how you want to perform
databinding in the main control itself but that's another task.
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke
child controls. How would I (within a Control subclass) _just_ perform
databinding for the current control, and not the children?
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.