Necessity, the mother of invention

  • Twitts

    Error: Twitter did not respond. Please wait a few minutes and refresh this page.

  • RSS My Reader

    • An error has occurred; the feed is probably down. Try again later.
  • Top Clicks

    • None
  • Advertisements
  • Visitor Map

    Locations of Site Visitors
  • Flag Counter

    free counters

Pass Eval value in javascript function from GridView

Posted by Navi's on February 2, 2011

In Gridview, some times we need to pass (Eval(“Column”)) value in javascript function on LinkButton or HyperLink. But you can not 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});")%>' />

This is the best way to pass eval value in javascript function from GridView’s LinkButton / HyperLink.

enjoy 🙂



9 Responses to “Pass Eval value in javascript function from GridView”

  1. guru2friends said

    Thanks Navi, This is what I looked for long time. It is working fine.

  2. shwetamber said

    its not working for me. The Final html will be

    Now javascript function will gives error – Abheri is not defined.

    I don’t get the alert message. below is javascript function.

    function test(pnl)

  3. malek said

    if we have 2 eval value; how can we pass them?

  4. kinjal shah said

    Thank’s Navi

  5. Anna-Pia said

    Thank you! After going through tons of suggestions this finally helped me out.

  6. subbu said

    Hi All,
    The below code works fine for me in the ImageButton

    Please help me out how to implement the same in OnClientClicked, i am using using the <Telerik:RadButton

    OnClientClicked —

  7. diggerz said

    shot maamz. exactly what i was looking for

  8. Bibz said

    Thanks I wasted 4 hrs searching for right answer and trying many answers…none could help me until I found this. Gr8 job…:)

  9. Miguel said

    Muchas gracias me has ahorrado varias horas de pruebas

    Translated : Thank you very much you’ve saved me several hours of testing

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: