I have a GridView with textboxes in its cells. A JavaScript function is called on changing textbox’s contents. I want to pass to the function a data key of the row to which the textbox belongs, but don’t know how I can do that.
The following gives me an error message:
<asp:TextBox ID="txtWFShipDate" runat="server"
Text='<%#Eval("StrShipDate") %>' BorderStyle="None" Width="80%"
CssClass="date"
onchange="JSSaveWorkflowChanges(this, '<%# Eval("BookStemCommon") %>');">
</asp:TextBox>
BookStemCommon is the data key name.
Try like this:
or a better and safer way using JavaScriptSerializer to properly encode the value that will be passed to the javascript function: