Saturday, January 4, 2014

Get GridView Cell value using jQuery ASP.NET

In this tutorial I will show you how you can get the cell value of Grid View using jQuery

You will first need to populate your gridview using any datasource

than using the jquery below

$("#<%=gv1.ClientID %> tr").each(function () {
                    if (!this.rowIndex) return;
                    var row = $(this).find("td:first");
                    alert(row[0].innerText);
                });
gv1 is the name of our gridview

using the each loop we iterate on each row

td:first indicate that we are only getting value of first column

we can also use

td:last
td:even
td:odd
td:eq("index number")
td:gt("Include element that are past the given index")
td:lt("Include element that are before the given index")
td:not()

I hope it was informative for you and I would like to Thank you for reading