Reputation: 639
Is there anyway to loop through a nested gridview? This is the javascript I have so far, I don't think I'm far off a solution:
$(document).ready(function() {
$("#<%=gvAdmin.ClientID %> tr").each(function() {
$(this).find(".gvSubMain tr").each(function() {
var hdnDate = $(this).find(".Date").val();
//Do Stuff
});
});
});
The two gridviews are; a major gridview called gvAdmin, and the nested gridview called gvSubAdmin. I have looked at this problem for quite a while and see variations such as:
$(document).ready(function() {
$("#<%=gvAdmin.ClientID %> tr").each(function() {
$(this).find(".gvSubMain > tr").each(function() {
var hdnDate = $(this).find(".Date").val();
//Do Stuff
});
});
});
And another variation:
$(document).ready(function() {
$("#<%=gvAdmin.ClientID %> tr").each(function() {
$(this).find(".gvSubMain").find("tr").each(function() {
var hdnDate = $(this).find(".Date").val();
//Do Stuff
});
});
});
But none of these work, is it a small syntax problem that I'm struggling with or is it something in my logic? Do I need to used the .find(".gvSubMain")
or can I call the gridview some other way?
Thanks,
Firstcape
Upvotes: 1
Views: 1323
Reputation: 73966
Try this:
$(document).ready(function () {
$("#<%=gvAdmin.ClientID %> > tbody > tr").each(function () {
$(this).find(".gvSubMain > tbody > tr").each(function () {
var hdnDate = $(this).find(".Date").val();
//Do Stuff
});
});
});
Upvotes: 2