My contemplations and diurnal novelties are publicized here

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”))%>




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: