문제

how to put <%# DataBinder.Eval(Container, "DataItem.Code") %> to string in aspx file? like <% string str = DataBinder.Eval(Container, "DataItem.Code") %>? I am getting error The name 'Container' does not exist in the current context

도움이 되었습니까?

해결책

You could write a helper function in your code behind which will return the required string:

protected string MyFunction(object item)
{
    ... do some calculations and return a string
}

and then in your view whenever you needed the value you could call this function:

<%# MyFunction(DataBinder.Eval(Container, "DataItem.Code")) %>

This way you no longer need a variable.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top