Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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.
 
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 17-Apr-13 22:49pm
Edited 18-Apr-13 21:59pm
v7
Comments
Tadit Dash at 18-Apr-13 4:50am
   
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.
TusharKhairnar at 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);
}
}
TusharKhairnar at 18-Apr-13 6:03am
   
or try this:-
$('#GridView1 tr:last .ProdID').text();
patel_vijay at 18-Apr-13 6:51am
   
Also if possible post html rendered by GridView

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
$('#gridview1 tr:last').find('td:first').html()
  Permalink  
Comments
arbaaz jalil at 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 at 19-Apr-13 2:31am
   
I am posing a part of the generated html code
patel_vijay at 19-Apr-13 2:32am
   
Post your html so i can check or post it on jsFiddle and provide link over here
patel_vijay at 19-Apr-13 2:42am
   
In your HTML code there are a lot of unclosed tags, please post proper html
arbaaz jalil at 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
arbaaz jalil at 19-Apr-13 2:59am
   
@patel http://jsfiddle.net/LRSS2/1/
arbaaz jalil at 19-Apr-13 3:06am
   
the value which i want is 92 in this case since its the id of last row which has been loaded
patel_vijay at 19-Apr-13 4:14am
   
Checkout this link on jsFiddle. http://jsfiddle.net/LRSS2/3/
Also make sure that your grid render <tbody> element...
To render <tbody> element from GridView set following properties in GridView
 
grid.UseAccessibleHeader = true;
grid.HeaderRow.TableSection = TableRowSection.TableHeader;
arbaaz jalil at 19-Apr-13 4:25am
   
i added UseAccessibleHeader="True" in the GridView tag where and how should i write grid.HeaderRow.TableSection = TableRowSection.TableHeader;
patel_vijay at 19-Apr-13 4:37am
   
Now use jQuery that is used in sample in jsFiddle
$('table#ContentPlaceHolder1_GetUserScraps1_GridViewUserScraps>tbody>tr:last>td:first').html()
arbaaz jalil at 19-Apr-13 4:39am
   
It worked!! Great!! I could have never done this on my own without your help. How did you do it?
patel_vijay at 19-Apr-13 4:49am
   
It just a power of jQuery selectors.. You can learn more at http://api.jquery.com/category/selectors/
arbaaz jalil at 19-Apr-13 4:56am
   
Thanks a lot brother. How can i approach you if i ever have any question like this one? if its not too much to ask for.
patel_vijay at 19-Apr-13 5:02am
   
Sure dear
arbaaz jalil at 19-Apr-13 5:04am
   
how would i approach you? this site does not have messaging feature i guess.
patel_vijay at 19-Apr-13 7:19am
   
You can post your query here.
arbaaz jalil at 19-Apr-13 7:34am
   
okay Thanks. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 19 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100