How can I fix "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the conte
        Posted  
        
            by slolife
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by slolife
        
        
        
        Published on 2010-05-04T20:23:43Z
        Indexed on 
            2010/05/04
            20:28 UTC
        
        
        Read the original article
        Hit count: 263
        
I have a user control (ascx) that I have added two public properties to: RequestTypeId and GroupId. Both have the attribute set.
In my aspx page, I have a ListView, and in the ItemTemplate, I place my control reference, like so:
 <ctrl:ServiceTypeGroup runat="server" RequestTypeId="<%#RequestType.RequestTypeId%>" GroupId='<%#Eval("Id").ToString()%>' />
Setting the RequestTypeId works fine. Setting the GroupId fails with the following error:
"Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control."
What do I need to do to my user control code to allow binding a Eval() expression to one of its properties? Or is it not possible?
© Stack Overflow or respective owner