asp.net - multiplying rows in gridview without page refresh -


i have gridview web application in there quantity , unit price column , total column. if type quantity , unit price want display total price automatically in next column. current coding display after page reload clicking on add button only. need display total amount automatically when move total column. current code.

<itemtemplate>     <asp:textbox id="txttotal" runat="server"          text='<%# convert.toint32(eval("qty")) * convert.toint32(eval("uprice"))%>'          autopostback="true">     </asp:textbox> </itemtemplate>` 

you need invoke javascript function gridview rowdatabound below:

 txtfatobj.attributes.add("onkeyup", "calculate('" + txtfatobj.clientid + "','" + txtsnfobj.clientid + "','" + txtnetwtobj.clientid + "','" + txttsobj.clientid + "')"); 

calculate() defined on aspx page or in separate js file.you can calculate based on these parameters received , set value.

define rowdatabound need find controls , send captured values javascript.actual calculation occur @ javascript end.

protected void grvcalc_rowdatabound(object sender, gridviewroweventargs e)     {         if (e.row.rowtype == datacontrolrowtype.datarow)         {             textbox txtfatobj = (textbox)e.row.findcontrol("txtfat");             textbox txtsnfobj = (textbox)e.row.findcontrol("txtsnf");             textbox txtnetwtobj = (textbox)e.row.findcontrol("txtnetwt");             textbox txttsobj = (textbox)e.row.findcontrol("txtts");              txtfatobj.attributes.add("onfocusout", "calculate('" + txtfatobj.clientid + "','" + txtsnfobj.clientid + "','" + txtnetwtobj.clientid + "','" + txttsobj .clientid + "')");          }     } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -