Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sir, i have a Gridview. in which i take a textbox in a column. i need that when i enter numbers in gridview textbox then it calculate the sum of textbox and show one another textbox. my asp code is here:-


XML
<asp:GridView ID="GridOtherFee" runat="server" AutoGenerateColumns="false" CssClass="mGrid" DataSourceID="SqlOtherFee">
      <Columns>


          <asp:BoundField DataField="Abb" HeaderText="FeeHead" ReadOnly="True"  HeaderStyle-Width="100px"/>

          <asp:TemplateField SortExpression="Amount" HeaderText=" Amount" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right"  HeaderStyle-Width="150px">
              <ItemTemplate>
                  <asp:TextBox ID="TxtRecd"  runat="server" Width="100px" AutoPostBack="true" CssClass="aligntext"></asp:TextBox>
              </ItemTemplate>
          </asp:TemplateField>

      </Columns>

  </asp:GridView>



<asp:TextBox ID="txtFeeRecd" runat="server" name="a" Width="100px" ReadOnly="true" CssClass="aligntext" >



when i enter digits in gridview txtrecd textbox the sum of show in textfeereced textbox..
Posted
Comments
Praveen Kumar Upadhyay 16-Apr-15 3:26am    
Please show some more code.

1 solution

Call this Method on some button click or on new row creation or whatever event you want to

C#
private void GrandTotal()
    {
     float GTotal = 0f;
     for (int i = 0; i < GridView1.Rows.Count; i++)
     {
        String total = (GridView1.Rows[i].FindControl("lblTotal") as Label).Text;
        GTotal += Convert.ToSingle(total);
     }
     txtTotal.text=GTotal.toString();
    }


Hope it will help..
 
Share this answer
 
Comments
TCS54321 22-Apr-15 1:04am    
i want to do it from client side.

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