Reputation: 1287
I have the following gridview:
<asp:GridView ID="grdResults" runat="server" OnRowDataBound="grdResults_RowDataBound" DataKeyNames="rowNumber">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:TemplateField HeaderText="Seq">
<ItemTemplate >
<asp:LinkButton runat="server" Text='<%# Eval("Seq") %>' OnClientClick='<%#String.Format("alert({0},{1})", Eval("ID"), Eval("Seq")) %>'
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
I would like to pass both values from asp:BoundField
and asp:LinkButton
to a javascript function upon a click on the LinkButton. I have tried the above code which is similar to the accepted answer of this example but it doesn't work.
I'd appreciate any suggestions on how to do that.
Upvotes: 1
Views: 776
Reputation: 7465
Please try this instead:
OnClientClick='<%#string.Format("window.alert(""{0}""+""{1}"");",
DataBinder.Eval(Container.DataItem, "ID"),
DataBinder.Eval(Container.DataItem, "Seq")) %>'
Upvotes: 1