<script language="javascript"> function TestFunction() { alert("test message:" ) } </script> <asp:TemplateColumn HeaderText="txnotes"> <HeaderStyle Width="10%"></HeaderStyle> <ItemStyle Font-Size="XX-Small" Font-Names="Arial"></ItemStyle> <ItemTemplate> <asp:HyperLink runat="server" NavigateUrl='javascript:TestFunction()' Text='<%# DataBinder.Eval(Container, "DataItem.custid") %>' ID="link1" NAME="HyperLink21"> </asp:HyperLink> </ItemTemplate> </asp:TemplateColumn>After the grid is rendered I can click on the HyperLink, which displays a customer's ID (custid) because a set it in the Text attribute, and an alert window pops up.
<script language="javascript"> function TestFunction(tcCustID) { alert("test message:" + tcCustID) } </script>The next part is where I am lost. How to I pass custid ot the function? Based on how I am setting the Text attribute of the HyperLink, namely: Text='<%# DataBinder.Eval(Container, "DataItem.custid") %>', I thought I could do something similar like this but it does not work.
<asp:TemplateColumn HeaderText="txnotes"> <HeaderStyle Width="10%"></HeaderStyle> <ItemStyle Font-Size="XX-Small" Font-Names="Arial"></ItemStyle> <ItemTemplate> <asp:HyperLink runat="server" NavigateUrl='javascript:TestFunction(<%# DataBinder.Eval(Container, "DataItem.custid") %>)' Text='<%# DataBinder.Eval(Container, "DataItem.custid") %>' ID="link1" NAME="HyperLink21"> </asp:HyperLink> </ItemTemplate> </asp:TemplateColumn>