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
rakesh.sawan...
Member
168 Points
172 Posts
How to get textbox values from gridview using jquery
Nov 25, 2012 02:22 PM|LINK
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>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
chaaraan
Contributor
2170 Points
484 Posts
Re: How to get textbox values from gridview using jquery
Nov 25, 2012 02:43 PM|LINK
Hi,
You can use End Selectors for this case
var tr= $(this).parent("td").parent("tr");
var Email=$(this).parent("td").parent("tr").find($( "[ @id *= 'txtEmail']" )).val();
var Name= $(this).parent("td").parent("tr").find($( "[ @id *= 'txtName']" )).val();
Regards,
Charan
rakesh.sawan...
Member
168 Points
172 Posts
Re: How to get textbox values from gridview using jquery
Nov 25, 2012 02:52 PM|LINK
Tried your solution but not working
rajaron
Member
657 Points
202 Posts
Re: How to get textbox values from gridview using jquery
Nov 25, 2012 07:29 PM|LINK
Try this
<script type="text/javascript">
$(document).ready(function () {
$("#<%=gvEmployee.ClientID%> tr:has(td)").each(function () {
alert($(this).html());
});
});
</script>
abu_qusy
Member
223 Points
77 Posts
Re: How to get textbox values from gridview using jquery
Nov 25, 2012 07:39 PM|LINK
check this link
http://stackoverflow.com/questions/10944630/find-textbox-in-gridview-in-jquery
rakesh.sawan...
Member
168 Points
172 Posts
Re: How to get textbox values from gridview using jquery
Nov 27, 2012 03:45 PM|LINK
Just use class selector by giving some class to textbox
alert($(a).parent("td").parent("tr").find(".txtclass1").val());