i have gridview sum of rows dynamically , has delete button each row.
webform1.aspx
<asp:gridview id="grdview1" runat="server" autogeneratecolumns="false" showfooter="true"> <columns> <asp:templatefield headertext="s.no"> <itemtemplate> <asp:label id="lblsno" runat="server" text='<%#container.dataitemindex+1 %>'></asp:label> </itemtemplate> <itemstyle horizontalalign="center" borderwidth="1px" /> </asp:templatefield> <asp:templatefield headertext="particulars"> <itemtemplate> <asp:dropdownlist id="drpparticulars" runat="server" > </asp:dropdownlist> </itemtemplate> <footertemplate> <asp:label id="lbltotal" runat="server">total :</asp:label> </footertemplate> <itemstyle horizontalalign="left" borderwidth="1px" /> </asp:templatefield> <asp:templatefield headertext="amount"> <itemtemplate> <asp:textbox id="txtamount" runat="server" ontextchanged="txtamount_textchanged" autopostback="true"></asp:textbox> </itemtemplate> <footertemplate> <asp:label id="lbltotalamount" runat="server"></asp:label> </footertemplate> <itemstyle horizontalalign="left" borderwidth="1px" /> </asp:templatefield> <asp:templatefield headertext="edit record"> <itemtemplate> <asp:imagebutton id="imgdelete" runat="server" causesvalidation="false" commandname="delete" imageurl="~/images/cancel.png" tooltip="delete record" onclientclick="return confirm('are sure?');" text="delete" /> </itemtemplate> <footertemplate> <asp:imagebutton id="imgaddnewrow" runat="server" cssclass="gridimage" onclick="addnew_click" imageurl="~/images/addnew.png" tooltip="add new row" text="add row" /> </footertemplate> <itemstyle horizontalalign="center" /> </asp:templatefield> </columns> <footerstyle cssclass="header_order" /> </asp:gridview> my expected result:
s.no particulars amount edit record ----- ----------- ------ ----------- 1 item cr 2500 x 2 item cr 1500 x 3 item dr 3000 x ----------------------------------------- total 7000 + ----------------------------------------- now problem sum of amount row values while text_changed itself.
webform1.aspx.vb
protected sub txtamount_textchanged(sender object, e system.eventargs) dim tmpval integer = 0 integer = 0 grdview1.rows.count - 1 dim txtamount textbox = directcast(grdview1.rows(i).findcontrol("txtamount"), textbox) dim lbltotalamount label = directcast(grdview1.rows(i).findcontrol("lbltotalamount"), label) tmpval = tmpval + integer.parse(txtamount.text) lbltotalamount.text = tmpval.tostring() next end sub when cursor out of text box, automatically sum row values , bind result footer label column. have searched solution in stack overflow thoroughly, not apt question. asking question.
thanks..
i found result in way. created seperate table 1 row sum of total values. , working fine.
s.no particulars amount edit record ----- ----------- ------ ----------- 1 item1 cr 2500 x 2 item2 cr 1500 x 3 item3 dr 3000 x ----------------------------------------- + ----------------------------------------- total 7000 ----------------------------------------- webform1.aspx.vb
protected sub txtamount_textchanged(sender object, e system.eventargs) dim tmpval integer = 0 dim tmpcalval integer = 0 integer = 0 grdview1.rows.count - 1 dim txtamount textbox = directcast(grdview1.rows(i).findcontrol("txtamount"), textbox) tmpcalval = convert.toint32(txtamount.text) tmpval = tmpval + (tmpcalval) lbltotalpaymentval.text = tmpval.tostring() next end sub
Comments
Post a Comment