Control.DataBind()

Discussion in 'ASP .Net Building Controls' started by TheGG, Jun 12, 2004.

  1. TheGG

    TheGG Guest

    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?
     
    TheGG, Jun 12, 2004
    #1
    1. Advertising

  2. TheGG

    Teemu Keiski Guest

    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



    "TheGG" <> wrote in message
    news:...
    > 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?
     
    Teemu Keiski, Jun 12, 2004
    #2
    1. Advertising

  3. TheGG

    TheGG Guest

    Great, thanks!

    "Teemu Keiski" wrote:

    > 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
    >
    >
    >
    > "TheGG" <> wrote in message
    > news:...
    > > 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?
    >
    >
    >
     
    TheGG, Jun 12, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bryce Budd

    Control.DataBind() question

    Bryce Budd, Nov 28, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    462
    Bryce Budd
    Nov 28, 2004
  2. Olav Tollefsen
    Replies:
    2
    Views:
    1,894
    Olav Tollefsen
    Dec 29, 2004
  3. =?Utf-8?B?bWlrZQ==?=
    Replies:
    0
    Views:
    1,377
    =?Utf-8?B?bWlrZQ==?=
    May 16, 2005
  4. =?Utf-8?B?eXVjaGFuZw==?=
    Replies:
    0
    Views:
    528
    =?Utf-8?B?eXVjaGFuZw==?=
    Apr 15, 2006
  5. Michael
    Replies:
    0
    Views:
    226
    Michael
    Dec 29, 2003
Loading...

Share This Page