如何使用jQuery从GridView获取文本框值 [英] How to get textbox values from gridview using jquery

查看:105
本文介绍了如何使用jQuery从GridView获取文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在使用jQuery的链接按钮单击时从gridview文本框值,这是我的gridview

How to textbox values from gridview on click of a linkbutton using jquery here is my gridview

<asp:GridView ID="gvEmployee" runat="server" AutoGenerateColumns="false" GridLines="Both">
            <Columns>
                <asp:TemplateField HeaderText="Email">
                    <ItemTemplate>
                        <asp:TextBox ID="txtEmail" runat="server" Text=''<%#Eval("Emailid") %>''></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Name">
                    <ItemTemplate>
                        <asp:TextBox ID="txtName" runat="server" Text=''<%#Eval("Name") %>''></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="lnkgettext" runat="server" Text="Gettextboxvalue"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>


我尝试过类似的

alert($(this).parent("td").parent("tr").find("input:text").val());
我可以找到文本框的第一个值,但要从第二个td获取下一个文本框值(即txtName)时遇到问题,请提出建议,也建议您使用javascript


I tried something like

alert($(this).parent("td").parent("tr").find("input:text").val());
I Can able to find first value of a textbox but facing a problem to get next textbox value i.e txtName from second td Please suggest Also suggest if you have any solution with javascript

推荐答案

(this).parent("td").parent("tr").find("input:text").val());
我能够找到文本框的第一个值,但面临从第二个td获取下一个文本框值(即txtName)的问题,请提出建议也建议您是否有使用javascript的解决方案
(this).parent("td").parent("tr").find("input:text").val());
I Can able to find first value of a textbox but facing a problem to get next textbox value i.e txtName from second td Please suggest Also suggest if you have any solution with javascript


刚给出的解决方案将两个文本框的cssclass分别作为txtclass1和txtclass2

alert(
got solution just given cssclass to both textboxes as txtclass1 and txtclass2

alert(


(this).parent("td").parent("tr").find(.txtclass1").val());
警报(
(this).parent("td").parent("tr").find(".txtclass1").val());
alert(


这篇关于如何使用jQuery从GridView获取文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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