I have an existing GridView which contains the field "partner name". It is sortable by partner name.
Now I need to change the Partner Name field and in some condition make it clickable and alert() something.
The existing code is:
<asp:GridView ID="gridViewAdjustments" runat="server" AutoGenerateColumns="false" AllowSorting="True" OnSorting="gridView_Sorting" OnRowDataBound="OnRowDataBoundAdjustments" EnableViewState="true">
<asp:BoundField DataField="PartnerName" HeaderText="Name" SortExpression="PartnerName"/>
I've added the column:
<asp:hyperlinkfield datatextfield="PartnerName" SortExpression="PartnerName" headertext="Name" ItemStyle-CssClass="text2"/>
which enables me to control the CSS and sort. However, I can't find how to add a client side javascript function to it.
I found that adding :
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<a id="lnk" runat="server">Edit</a>
enable me to access "lnk" by id and add to its attributes. However, I lose the Sort ability.
What's the correct solution in this case?
Thanks.