How to call a function on a databound value in ListView

Wrap your Eval call:

Markup: <asp:LinkButton id=”whatever” runat=”server” Visible=’’<%# ShowHideLink(Eval(“Storage”)) %>


protected bool ShowHideLink(object obj)
bool result = false;
//cast obj to whatever datatype it is
int numOfProducts = (int)obj;

//do some evaluating
if(numOfProducts &gt; 10) //whatever your biz logic is
    result = true;

return result;


Jason Kulatunga

Build Automation & Infrastructure guy @Adobe. I write about, and play with, all sorts of new tech. All opinions are my own.

San Francisco, CA

Subscribe to Sparktree

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!