Search code examples
asp.netdataitem

How can i set a DataItem to some part of aspx code?


I have some code like this:

<div><%# DataBinder.Eval(Container.DataItem, "M_ClassProperty") %></div>
<img src='<%# DataBinder.Eval(Container.DataItem, "M_AnotherClassProperty").To<string>()  %>'

but there is no component which wraps this code like Repeater, DataList or something like that. How can set the set a DataItem to this code to show the values of an object of a class.

I hope i could tell clear (I don't think so but I HOPE :)


Solution

  • You can use normal inline code, like this:

    <div> <%= SomeObject.SomeProperty.ToString() %></div>
    

    To get an object, you can define a protected property in the code-behind page.