JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
1,060 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a gridview:
<asp:TemplateField HeaderText="First Name">
<ItemTemplate>
<asp:Label ID="fNameLbl" Text='<%# Bind("fName") %>' runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="fNameTxtBox" Text='<%# Bind("fName") %>' runat="server"></asp:TextBox>
<asp:Label ID="fNameErrorsLbl" CssClass="errorLabels" runat="server"></asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="editBtn" Text="Edit" CommandName="Edit" runat="server" />
</ItemTemplate>
<EditItemTemplate>
<asp:Button ID="updateBtn" Text="Update" CommandName="Update" runat="server" OnClientClick="checkGridView()" />
<asp:Button ID="cancelBtn" Text="Cancel" CommandName="Cancel" runat="server" />
</EditItemTemplate>
</asp:TemplateField>
I wanted to do so that when I click the update button to get the value from the cell in the row it was clicked to JS.
I tried this code:
function checkGridView() {
fNameV = document.getElementById('fNameTxtBox');
alert(fNameV);
}
But document.getElementById('fNameTxtBox') returns null. How can I fix it?