compositedataboundcontrol with template databinding problem

S

Samuel

Hi everyone,

I am new to this ASP.NET 2.0 feature. I am having a hard time getting the
databinding syntax evaluated in my template for a control that inherits the
CompositeDataboundControl that is new to ASP.NET 2.0. I don't have such
problem with a control that inherits from CompositeControl. The template
loads fine, but it is just that the databinding syntax won't evaluate. Here
is how I want it done:


<cc2:TableHeader2 ID="TableHeader2" runat="server"
EnableViewState="false" AutoPostBack="false" >

<ButtonSeparatorTemplate><hr width="<%# Container.SeparatorWidth
%>" /></ButtonSeparatorTemplate>

</cc2:TableHeader2>

As you can see from the above code, there is a template called
ButtonSeparatorTemplate. On the HTML source, I only get <hr width="" />
without the Container.SeparatorWidth being evaluated.

In this class, I override the CreateChildControls (IEnumerable, Boolean)
function and I don't know what I missed. There is not such problem when I
inherits the more general CompositeControl.

Thanks!
 
S

Samuel

I just want to add that databinding syntax is evaluated without any problem
on the control itself.

<cc2:TableHeader2 ID="TableHeader2" runat="server"
EnableViewState="false" width="<%# myWidth %>" >

<ButtonSeparatorTemplate><hr width="<%# Container.SeparatorWidth
%>" /></ButtonSeparatorTemplate>

</cc2:TableHeader2>

While <%# myWidth %> evaluates without any problem, I can't get <%#
Container.SeparatorWidth %> evaluated.

Thanks for any help you can provide me.
 
S

Steven Cheng[MSFT]

Hello,

Welcome to the MSDN newsgroup.

As for the custom webcontrol with Template, are you going to develop
template databound control like repeater, datalist ...? Based on my
understanding template databound control is abit different from normal
template control. Here is a msdn tech article ddemonstrate on creating a
template databound control(repeater like):

#Building DataBound Templated Custom ASP.NET Server Controls
http://msdn.microsoft.com/library/en-us/dnaspp/html/databoundtemplatedcontro
ls.asp?frame=true

also, the msdn doc also provide a sample control derived from
CompsoteDataBoundControl, we can also have a look.

#CompositeDataBoundControl Class
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.composite
databoundcontrol(VS.80).aspx


Hope this helps.

Regards,


Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may

learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
 

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,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top