views:

74

answers:

1

I have a grid view populating by users, i want to add to it a link which will call a javascript function "showUser({userid})".

I wrote it like this:

<asp:TemplateField>
            <ItemTemplate> 
                <a href="javascript:ShowUser(<%# Bind('UserId') %>)" runat="server" >Edit</a>
            </ItemTemplate>
        </asp:TemplateField>

But the problem that the link goes to "javascript:ShowUser(<%#%20Bind('UserId')%20%>)" instead of getting the user id and call the function with.

What i am missing to make that work?

A: 

Got a solution to write it like that:

<a href='<%#"javascript:ShowUser(" + Eval("UserID")+")"%>' runat="server" >Edit</a>

and it worked.

Amr ElGarhy