使用Jquery在gridview中添加Texbox [英] Adding Texbox in gridview using Jquery

查看:76
本文介绍了使用Jquery在gridview中添加Texbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个gridview


I have a gridview


<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>




它有四个名为
的文本框
txtTest,txtComponent,txtAttendence和txtTotal

我需要使用公式
的结果




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



如何使用jquery

我推荐了以下链接..但它用于计算绑定字段..但我需要模板字段

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



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?

推荐答案

您的麻烦将是,您需要确定如何识别模板行.这些ID是自动生成的,这就是为什么jquery和asp.net不如mvc和jquery合适的原因.如果您可以在用户按下的行中放置一个按钮,则可能会为您提供上下文,如果您使用"this"传递该按钮,则可以找到该行并从该行中获取字段,甚至索引而不是名称.第一步是检查HTML并找出您需要搜索的ID或在这方面的选择.
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.


这篇关于使用Jquery在gridview中添加Texbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆