Click here to Skip to main content
15,917,859 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to implement Load GridView on scroll down it seems to read the first td of last tr of the table generated by GridView on runtime to get the value of last productid which has been loaded. The problem is that when i tried to implement that article in a USerControl (which is a nested GridView) it seems value which i being set to LastProduct id is not correct. I used alert to findout the value of LastProduct id on scroll down and i got a weird lengthy html sort of value.

XML
function BindNewData() 
{
           var lastProductId = $("#<%=GridViewUserScraps.ClientID %> tr:last").children("td:first").html();



The GridView has a bound column at the begining which has id. So ideally the value of the LastProduct should be the a number ( last row' first column value)


HTML code generated in runtime:

http://jsfiddle.net/LRSS2/1/
Posted
Updated 18-Apr-13 20:59pm
v7
Comments
Try to figure out the position of that "td" in rendered html.
Then only you can decide how to get that id by jQuery selector.
You can also check in FireBug of FireFox.
TrushnaK 18-Apr-13 5:57am    
did you mean to say you want last rows first column value. then try for this

function GetValues()
{
var table = document.getElementById('<%=GridView1.ClientID %>');
for (var i = 1; i < table.rows.length; i++)
{
var Row = table.rows[i];
var CellValue = Row.cells[2].innerText;
document.writeln(CellValue);
}
}
TrushnaK 18-Apr-13 6:03am    
or try this:-
$('#GridView1 tr:last .ProdID').text();
vijay__p 18-Apr-13 6:51am    
Also if possible post html rendered by GridView

1 solution

Checkout below link
http://jsfiddle.net/LRSS2/[^]

Here i have created one html table with 6 rows, each row having first column with different id value.
Using jQuery it will find last row first colunm value
JavaScript
$('#gridview1 tr:last').find('td:first').html()
 
Share this answer
 
Comments
arbaaz jalil 19-Apr-13 2:27am    
When i use your code its giving me null. perhaps you guys need to see the html which is being generated but its very lengthy
arbaaz jalil 19-Apr-13 2:31am    
I am posing a part of the generated html code
vijay__p 19-Apr-13 2:32am    
Post your html so i can check or post it on jsFiddle and provide link over here
vijay__p 19-Apr-13 2:42am    
In your HTML code there are a lot of unclosed tags, please post proper html
arbaaz jalil 19-Apr-13 3:11am    
I have posted the link to jsfiddle , let me know if there is anything else you want me to do

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