Click here to Skip to main content
15,905,144 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have a gridview


XML
<asp:GridView ID="gdvInternallist" runat="server" Caption="InternalMarkEntry" CssClass="Grid"
                EmptyDataText="No Record found" Width="100%"

                  AutoGenerateColumns="False"
             >
                <HeaderStyle CssClass="GridHeader" />
                <AlternatingRowStyle CssClass="GridAltItem" />
                <Columns>



                        <asp:TemplateField HeaderText="Name" >

                              <ItemTemplate>
                                      <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>' ></asp:Label>

                              </ItemTemplate>
                     </asp:TemplateField>

                          <asp:TemplateField >
                          <HeaderTemplate>
                       <asp:Label ID="lblTest" runat="server" ></asp:Label>
                     </HeaderTemplate>
                              <ItemTemplate>
                                  <asp:TextBox ID="txtTest" runat="server" Height="24px" Width="73px" Text="2"
                                    ></asp:TextBox>

                              </ItemTemplate>
                     </asp:TemplateField>
                     <asp:TemplateField>
                     <HeaderTemplate>
                       <asp:Label ID="lbComponent" runat="server" ></asp:Label>
                     </HeaderTemplate>
                         <ItemTemplate>
                             <asp:TextBox ID="txtComponent" runat="server" Height="24px" Width="73px"></asp:TextBox>

                         </ItemTemplate>
                     </asp:TemplateField>
                     <asp:TemplateField >
                      <HeaderTemplate>
                       <asp:Label ID="lblAttendence" runat="server" ></asp:Label>
                     </HeaderTemplate>
                         <ItemTemplate>
                             <asp:TextBox ID="txtAttendence" runat="server" Height="24px" Width="73px"
                                 ></asp:TextBox>

                         </ItemTemplate>
                     </asp:TemplateField>
                       <asp:TemplateField >
                      <HeaderTemplate>
                       <asp:Label ID="lblTotal" runat="server" ></asp:Label>
                     </HeaderTemplate>
                         <ItemTemplate>
                             <asp:TextBox ID="txtTotal" runat="server" Height="24px" Width="73px"  Text="0"></asp:TextBox>

                         </ItemTemplate>
                     </asp:TemplateField>
                </Columns>
            </asp:GridView>



and it has 4 textboxes named

txtTest,txtComponent,txtAttendence and txtTotal

I need the result using formula

txtTotal.Text=txtComponent.Text+txtAttendence.Text+ txtTest.Text


How it is possible using jquery

I reffered the following link ..but it is used to calculate bound field..but i need template field

http://www.aspsnippets.com/Articles/Calculate-Row-Total-and-Grand-Total-in-ASPNet-GridView-using-jQuery.aspx[^]


can anyone help me?
Posted

1 solution

Your trouble will be, you need to work out how to identify your template row. These ids are auto generated, which is why jquery and asp.net are not as good a fit as mvc and jquery. If you can put a button in to your row that the user presses, that might give you the context, if you pass that button in using 'this', to find the row and grab the fields from that row, perhaps even by index instead of name. Your first step is to examine your HTML and work out the ids you need to search for, or what your options are in that regard.
 
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