I'm confused to the difference that CreateChildControls and PerformDataBinding have in the CompositeDataBoundControl; would anybody have an example with this control, or understand the differences in purpose?
Thanks.
Brian
"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4).
In a DataBoundControl, you override CreateChildControls and PerformDataBinding seperately. In the CompositeDataBoundControl, you just override CreateChildControls. According to MSDN, you shouldn't override PerformDataBinding in the CompositeDataBoundControl.
What I've seen in CreateChildControls is that when dataBinding == true, the dataSource contains the data selected by the data source control. If dataBinding == false, then dataSource is an array of null objects, the length of which is the number you returned
from that method last time...I haven't found out why this is useful.
This article has a good method for saving data and preventing unnecessary databinding.
Thanks for the information, that makes sense. The array of null objects is useful because you are supposed to loop through and create the child controls; the viewstate will then load the information back in. I remember reading that from Nikhil Kothari's
ASP.NET server controls book.
Thanks for your help.
Brian
"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4).
So are you supposed to set controls into the array of null objects? From what I can see in Reflector, the only thing that control saves to ViewState for you is the int number you return from CreateChildControls. And looking at other controls that inherit from
this, it's for the most part used as a count (ie, in GridView how many rows there were).
Do you have a reference to where you saw details about that array? Does anyone else have any idea what it's for?
I'm reading that from the book I have; it states that whenever creating a new tablerow (example was creating a table), as soon as the table row is loaded from the "blank" data source, theviewstate is loaded for that row.
Brian
"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4).
bmains
All-Star
29116 Points
5886 Posts
MVP
CreateChildControls/PerformDataBinding
Jan 11, 2006 06:36 PM|LINK
Hello,
I'm confused to the difference that CreateChildControls and PerformDataBinding have in the CompositeDataBoundControl; would anybody have an example with this control, or understand the differences in purpose?
Thanks.
"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4).
jazzman42379
Member
191 Points
42 Posts
Re: CreateChildControls/PerformDataBinding
Jan 11, 2006 06:55 PM|LINK
Hey Brian,
I am going through the same thing right now...
In a DataBoundControl, you override CreateChildControls and PerformDataBinding seperately. In the CompositeDataBoundControl, you just override CreateChildControls. According to MSDN, you shouldn't override PerformDataBinding in the CompositeDataBoundControl. What I've seen in CreateChildControls is that when dataBinding == true, the dataSource contains the data selected by the data source control. If dataBinding == false, then dataSource is an array of null objects, the length of which is the number you returned from that method last time...I haven't found out why this is useful.
This article has a good method for saving data and preventing unnecessary databinding.
HTH,
John
bmains
All-Star
29116 Points
5886 Posts
MVP
Re: CreateChildControls/PerformDataBinding
Jan 12, 2006 11:42 AM|LINK
Hey,
Thanks for the information, that makes sense. The array of null objects is useful because you are supposed to loop through and create the child controls; the viewstate will then load the information back in. I remember reading that from Nikhil Kothari's ASP.NET server controls book.
Thanks for your help.
"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4).
jazzman42379
Member
191 Points
42 Posts
Re: CreateChildControls/PerformDataBinding
Jan 12, 2006 02:01 PM|LINK
Do you have a reference to where you saw details about that array? Does anyone else have any idea what it's for?
Thanks in advance,
John
bmains
All-Star
29116 Points
5886 Posts
MVP
Re: CreateChildControls/PerformDataBinding
Jan 12, 2006 07:09 PM|LINK
I'm reading that from the book I have; it states that whenever creating a new tablerow (example was creating a table), as soon as the table row is loaded from the "blank" data source, theviewstate is loaded for that row.
"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4).