compositedataboundcontrol with template databinding problem

Discussion in 'ASP .Net Building Controls' started by Samuel, Mar 23, 2006.

  1. Samuel

    Samuel Guest

    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!
    Samuel, Mar 23, 2006
    #1
    1. Advertising

  2. Samuel

    Samuel Guest

    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.
    Samuel, Mar 23, 2006
    #2
    1. Advertising

  3. 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.
    Steven Cheng[MSFT], Mar 24, 2006
    #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. Umut Tezduyar
    Replies:
    0
    Views:
    395
    Umut Tezduyar
    Jun 29, 2006
  2. Umut Tezduyar
    Replies:
    0
    Views:
    694
    Umut Tezduyar
    Jul 2, 2006
  3. Umut Tezduyar
    Replies:
    2
    Views:
    2,036
    Umut Tezduyar
    Jul 6, 2006
  4. Jos
    Replies:
    1
    Views:
    157
  5. Jos
    Replies:
    0
    Views:
    116
Loading...

Share This Page