C# 带有函数和其他变量的WebForms Eval()

C# 带有函数和其他变量的WebForms Eval(),c#,webforms,C#,Webforms,我试图从asp:ListView中的wordpress提要中评估日期。我想要的是将b“返回”到ItemTemplate,但我一直收到以下错误: {“Eval()、XPath()和Bind()等数据关联方法只能在控件数据绑定的上下文中使用。”}在.aspx上 <% DateTime date; var culture = new System.Globalization.CultureInfo("pt-BR"); DateTime.TryParseExact(Eva

我试图从asp:ListView中的wordpress提要中评估日期。我想要的是将b“返回”到ItemTemplate,但我一直收到以下错误:

{“Eval()、XPath()和Bind()等数据关联方法只能在控件数据绑定的上下文中使用。”}在.aspx上

<%
    DateTime date;
    var culture = new System.Globalization.CultureInfo("pt-BR");

    DateTime.TryParseExact(Eval("pubDate").ToString(), "dd MMM", culture, System.Globalization.DateTimeStyles.AssumeLocal, out date);

    var b = date.ToString();
 %>
<%# ToDate(Eval("pubDate")) %>
    protected string ToDate(object wordpressDate)
    {
        DateTime date;
        var culture = new System.Globalization.CultureInfo("pt-BR");

        DateTime.TryParse(wordpressDate.ToString(), culture, System.Globalization.DateTimeStyles.AssumeLocal, out date);

        return date.ToString("dd MMM");
    }