using eval in server side code on asp.net page

Posted by Sumit Sharma on Stack Overflow See other posts from Stack Overflow or by Sumit Sharma
Published on 2010-04-20T02:26:49Z Indexed on 2010/04/20 2:33 UTC
Read the original article Hit count: 350

Filed under:
|
<asp:Repeater ID="rptrParent" runat="server">
<ItemTemplate>
        <li>
            <a href="<% =ResolveUrl("~/cPanel/UserView.aspx?User=")%><%# Eval("StudentUserName") %>">
                <span>
                    <%  ProfileCommon pc = new ProfileCommon();
                        pc.GetProfile(Eval("StudentUserName").ToString());
                        Response.Write(pc.FirstName + "" + pc.LastName);
                    %>
                    <%# Eval("StudentUserName") %>
                </span>
            </a>
        </li>
</ItemTemplate>

The following error

Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.

is coming in this part

<%  ProfileCommon pc = new ProfileCommon();
    pc.GetProfile(Eval("StudentUserName").ToString());
    Response.Write(pc.FirstName + "" + pc.LastName);
%>

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-membership