/    Sign up×
Community /Pin to ProfileBookmark

"Check All" checkbox wrongly select another gridview

I had 3 different gridview in same asp page, each gridview have its own ‘Check All” checkbox button in header and a checkbox in each row of the gridview as I need to do some batch update & insert for selected rows.

my problem is that if I check the “Check All” checkbox in either one gridview, it will check all the checkbox in this page. I had already declared the gridview id in th code.

how can i control the “check All” checkbox to check the checkbox in its own gridview only ? Thanks.

[CODE]function selectAllGridview1(id) {

var grid = document.getElementById(“<%= GridView1ClientID %>”);
var cell;

if (grid.rows.length > 0) {
for (i = 1; i < grid.rows.length; i++) {
cell = grid.rows[i].cells[0];

for (j = 0; j < cell.childNodes.length; j++) {
if (cell.childNodes[j].type == “checkbox”) {
cell.childNodes[j].checked = document.getElementById(id).checked;
}
}
}
}
}[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@joeyanauthorMar 02.2011 — there is a typo mistake in the code, should be...

var grid = document.getElementById("<&#37;= GridView1.ClientID %>");

(i can't edit my post)
Copy linkTweet thisAlerts:
@JMRKERMar 02.2011 — I have no clue if this will make any difference, but you might try:
<i>
</i>var grid = document.getElementById("&lt;&amp;#37;="+ GridView1.ClientID+ "%&gt;");
×

Success!

Help @joeyan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...