My contemplations and diurnal novelties are publicized here

Archive for April 16, 2012

Eval not working


In Gridview, sometimes we need to pass (Eval(“Column”)) value in javascript function on LinkButton or HyperLink. But you cannot directly pass eval value in javascript function like this

    <asp:LinkButton id=’lnk’ runat=’server’ OnClientClick=’javascript:somefun(‘<%# Eval(“columnname”) %>’)’ />

This will give error. To resolve this problem we need to use bellow syntax.

    <asp:LinkButton id=’lnk’ runat=’server’ OnClientClick='<%#Eval(“columnname”,”javascript:somefun({0});”)%>

If we need to have more than 2 Parameter then we can use

<%# String.Format(“..\\filepath\\{0}\\{1}.jpeg”, Eval(“code”), Eval(“code”))%>

 

 

%d bloggers like this: