I have asp.net gridview with javascript calculation
<pre lang="Javascript">
function UpdateArea(cname) {
var Height = cname.find('#txtHeight').val();
var Length = cname.find('#txtLength').val();
var Area = cname.find('#txtArea').val();
if (isNaN(parseFloat(Height))) {
Height = 0;}
if (isNaN(parseFloat(Length))) {
Length = 0;}
var Amount = parseFloat(Length) * parseFloat(Height);
cname.find('#txtArea').val(Amount.toFixed(2));}
when i'm binding data to the gridview only showing databound fileds. textbox values are not showing. please help
<asp:GridView ID="gdComponent" runat="server" AutoGenerateColumns="False" Font-Size="12px" CssClass="table table-striped table-bordered table-hover" TabIndex="3" AllowSorting="True" Width="100%" >
<AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
<Columns>
<asp:BoundField HeaderText="Component" DataField="ComponentName" SortExpression="ComponentName">
<HeaderStyle ForeColor="White" BackColor="#337ab7" Width="10%" HorizontalAlign="Left" />
</asp:BoundField>
<asp:TemplateField HeaderText="Length">
<ItemTemplate>
<asp:TextBox ID="txtLength" runat="server" Text='<%# Bind("Length","{0:0.00}") %>'
Width="50px" onKeyup="UpdateArea($(this).parent().parent())" onblur="UpdateArea($(this).parent().parent())"
CssClass="contentTransparent" MaxLength="7" ClientIDMode="AutoID" ></asp:TextBox>
</ItemTemplate>
<HeaderStyle ForeColor="White" BackColor="#337ab7" Width="5%" HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Right" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Height">
<ItemTemplate>
<asp:TextBox ID="txtHeight" runat="server" Text='<%# Eval("Height","{0:0.00}") %>'
Width="50px" CssClass="content-right" MaxLength="12" ClientIDMode="AutoID" onkeypress="return isNumberKey(event)"
ReadOnly="true" onKeyup="UpdateArea($(this).parent().parent())" onblur="UpdateArea($(this).parent().parent())"></asp:TextBox>
</ItemTemplate>
<HeaderStyle ForeColor="White" BackColor="#337ab7" Width="5%" HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Right" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Area">
<ItemTemplate>
<asp:TextBox ID="txtArea" runat="server" Text='<%# Bind("Area","{0:0.00}") %>'
Width="50px" CssClass="contentTransparent" MaxLength="7" ClientIDMode="Static"></asp:TextBox>
</ItemTemplate>
<HeaderStyle ForeColor="White" BackColor="#337ab7" Width="5%" HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Right" />
</asp:TemplateField>
</Columns>
<PagerStyle CssClass="pgr"></PagerStyle>
<HeaderStyle CssClass="gridline" BackColor="DarkBlue" />
</asp:GridView>
What I have tried:
Load data to gridview textboxes. But only showing databound fileds