views:

59

answers:

2
<ItemTemplate>
        <%# ShowDescription((ClassName) Eval("this")) %>
</ItemTemplate>

I bind a list of objects to my gridview and in my gridview want to evaluate (call a function on) the bound object or bound object by row. Not the property of the bound object but the object itself. The above code obviously gives me an error and

<ItemTemplate>
        <%# ShowDescription((ClassName) this) %>
</ItemTemplate>

means it tries to parse the aspx page

So How can I evaluate the bound object in a grid view or I can't at all

+2  A: 

Have you tried the following:

<ItemTemplate>
        <%# ShowDescription((ClassName)Container.DataItem) %>
</ItemTemplate>
patmortech
A: 

Try the following:

<ItemTemplate>
   <asp:Label ID="lblDesc" runat="server" Text='<%# ShowDescription((ClassName) Eval("this")) %>'></asp:Label>     
</ItemTemplate>
Himadri