Pages

Oct 26, 2012

How to pass Eval value to javascript function from GridView ItemTemplate

Passing the Eval value to a javascript method is bit tricky.

You cannot pass directly as shown below.

<asp:LinkButton id='lnk' runat='server' OnClientClick='<%#Eval("columnname",
"javascript:testfun({0});")%>' />

Instead , the below way should work

<asp:LinkButton id='lnk' runat='server' OnClientClick='<%#Eval("columnname",
"javascript:testfun({0});")%>' />

No comments: