Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
Hi friends,
I am using C#,asp.net, .net framework2.
I am using the following javascript

<script type="text/javascript">

function funcsum(id)

{


var table = document.getElementById("grdView");




var sum = 0;

var mess=0;

var mess1=0;

mess=table.rows[id].cells[7].getElementsByTagName("input")[0].value;

mess1=table.rows[id].cells[8].getElementsByTagName("input")[0].value;



sum=parseFloat(mess.replace(",","."))+parseFloat(mess1.replace(",","."));







var grid = document.getElementById("<%= grdView.ClientID %>");

//sum = grid.rows[1].cells[7].childNodes[0].value;

grid.rows[id].cells[9].childNodes[0].value = sum;





}



</script>

i am using a hidden field

<asp:HiddenField ID="HFRowNo" runat="server" Value='<%# Eval("rowNo") %>' />



I have to pass the value of rowno to javascript function in the textbox of  template column.
How to do this?


<asp:TemplateField HeaderText="P &amp; L As Per Book">

<ItemStyle Width="80px" BackColor="White"/>

<ItemTemplate>

<asp:TextBox Width="80px" ID="txtPL" runat="server" text='<%# Eval("PL") %>' BorderStyle="None" BorderColor="white" OnChange="funcsum(<%# Eval("rowNo") %>)" AutoPostBack="false" >

</asp:TextBox>

</ItemTemplate>

<FooterTemplate>

<asp:Label ID="lblFPL" runat="server" />

</FooterTemplate>


<ControlStyle Width="80px" />

</asp:TemplateField>
Posted

Use the clientId property of the hiddenfield to write the client side id to your javascript, then look it up by it's id.
 
Share this answer
 
Comments
raju melveetilpurayil 30-Jun-11 8:01am    
my 5 :)
You simply have to use
JavaScript
var hdvalue = document.getElementById('Hidden1').value
this will give you the value inside the hidden field inside javascript.
 
Share this answer
 
Comments
raju melveetilpurayil 30-Jun-11 8:02am    
My 5 :) implement what Christian Graus said.
Change

OnChange="funcsum(<%# Eval("rowNo") %>)"

to

OnChange=<%# String.Format("javascript:funcsum('{0}')",Container.DataItemIndex)%>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900