Reputation: 26
I have a asp:DataGrid (Assume as Grid A) which has several asp:BoundColumn and asp:TemplateColumn inside..
One of the asp:TemplateColumn has another asp:DataGrid (Assume as Grid B)inside it ,
I want to get a value from a textbox onkeyup which is in Grid B and return it after calculation using Javascript or JQuery..
<asp:DataGrid ID="dgfloor" runat="server" AutoGenerateColumns="False" CssClass="table table-bordered table-striped mb-0"
ShowFooter="true" Width="100%">
<PagerStyle HorizontalAlign="Right" NextPageText="Next" PrevPageText="Prev" />
<Columns>
<asp:DataGrid ID="dgfloor" runat="server" AutoGenerateColumns="False" CssClass="table table-bordered table-striped mb-0"
ShowFooter="true" Width="100%">
<PagerStyle HorizontalAlign="Right" NextPageText="Next" PrevPageText="Prev" />
<Columns>
<asp:BoundColumn DataField="Data1" HeaderText="Already Completion%" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="100px"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Current Completion%" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="100px">
<ItemTemplate>
<asp:TextBox ID="txtData2" Width="70" runat="server" Text='<%#Eval("Percentage") %>' />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Completion Amount" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="100px">
<ItemTemplate>
<asp:Label ID="lblData3" Text='<%#Eval("Completionamt") %>' runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</Columns>
<script type="text/javascript">
var grid = document.getElementById("<%= dgwork.ClientID %>");
for (var i = 1; i < grid.rows.length; i++) {
var grid2 = grid.rows[i].cells[6].childNodes[0].value;
for (var i = 1; i < grid2.rows.length; i++) {
var one = grid2.rows[i].cells[7].childNodes[0].value;
alert(one);
}
}
</script>
To test it I have tried this JS to check whether its getting the value from the Grid B but it dint work..
The actual thing is i need to get the value from grid b and calculate it
when I change the value in Current Completion% textbox it should calculate Already Completion%*Amount and display it in Completion Amount (calculations should be done in script)
Upvotes: 0
Views: 16