Not sure how to write server variables to ItemTemplate

2 posts, 1 answers
  1. J
    J avatar
    143 posts
    Member since:
    Jun 2006

    Posted 23 Mar 2010 Link to this post

    I have the following code and it seems to work fairly well:

    <table cellpadding="0" border="0" cellspacing="0">  
        <tr> 
            <td><%= Class.Property %></td>  
        </tr> 
    </table> 
     

    Now the problem is that the data doesnt get written when I place the previous code in a RadPanelBar ItemTemplate:
    <telerik:RadPanelBar ID="SummaryPanelBar" runat="server">  
        <Items> 
            <telerik:RadPanelItem Text="General">  
                <ItemTemplate> 
    <table cellpadding="0" border="0" cellspacing="0">  
        <tr> 
            <td><%= Class.Property %></td>  
        </tr> 
    </table> 
                </ItemTemplate> 
            </telerik:RadPanelItem> 
        </Items> 
    </telerik:RadPanelBar> 
     

    Any clue as to why?

    J
  2. Answer
    Simon
    Admin
    Simon avatar
    2281 posts

    Posted 26 Mar 2010 Link to this post

    Hi J,

    The "<%= %>" used in a value of a property in the declarative markup of a control do not work as expected. The expressions are intended to write some HTML directly to the output stream when the page is actually being written (to the stream).

    You can use a binding expression "<%# %>", which assigns the evaluated result to the respective property, e.g.
    <telerik:RadPanelBar ID="SummaryPanelBar" runat="server"
        <Items>
            <telerik:RadPanelItem Text="General"
                <ItemTemplate>
    <table cellpadding="0" border="0" cellspacing="0"
        <tr>
            <td><%# Class.Property %></td
        </tr>
    </table>
                </ItemTemplate>
            </telerik:RadPanelItem>
        </Items>
    </telerik:RadPanelBar>

    This, however will only work when the respective Item's DataBind method has been called or (the DataBind method of the parent RadPanelBar).

    Sincerely yours,
    Simon
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top