我无法在gridview jquery中找到checkboxlist id [英] I am unable to find the checkboxlist id in gridview jquery
问题描述
在我的gridview中:
< itemtemplate >
< asp:checkbox1 runat = 服务器 id =
checkbox1 >
< asp:checkbox1ist runat < span class =code-keyword> = 服务器 id = cbklist >
< / itemtemplate >
选择option1时我无法找到控制复选框ID。
< pre lang =JavaScript> $( [id * = chkOption1])。on(< span class =code-string> 点击, function (){
$ .ajax({
type: POST,
url: AdminInitiateCollection.aspx / GetCollectionAreas,
data:' {}',
contentType: application / json; charset = utf-8,
dataType: json,
成功:OnSuccess,
失败: function (响应){
// alert(response.d);
}
});
});
function OnSuccess(响应){
var chkOption1 = $ ( this );
var grid = $( this )。nearest( table);
var dtcollection = response.d; // 这里我的输出是[har d disk,hello,collection]
var ddCollection = dtcollection.split( ,);
var $ ctrls = $( #<%= gvInitiateCollection.ClientID%> tr input [id * ='cbCollectFor']);
alert($ ctrls);
for ( var i = < span class =code-digit> 0 ; i< ddCollection.length; i ++){
var isChecked = $( #<%= gvInitiateCollection.ClientID%> tr input [id * ='chkOption1 '])。是( :checked);
if (isChecked){
$ ctrls.find(' label:contains(' + ddCollection [i] + ' )')。prev()。prop(' checked',< span class =code-keyword> true );
} else {
$( this )。removeAttr( checked);
$( td,$(这个)。最近的( tr))。removeClass( selected);
$ ctrls.find(' label:contains(' + ddCollection [i] + ' )')。prev()。prop( ' 选中', false );
}
}
// });
}
我的尝试:
我从这一行收到错误。
var $ ctrls = $(#<%= gvInitiateCollection.ClientID %> tr输入[id * ='cbCollectFor']);
alert($ ctrls);
( [id * = chkOption1])。on( 单击, function (){
。 ajax({
类型: POST,
url: AdminInitiateCollection.aspx / GetCollectionAreas,
data:' {}',
contentType: application / json; charset = utf-8,
dataType: json,
成功:OnSuccess,
失败: function (响应){
// alert(response.d);
}
});
});
function OnSuccess(响应){
var chkOption1 =
( this );
var grid =
In my gridview:
<itemtemplate>
<asp:checkbox1 runat="server" id="
checkbox1" >
<asp:checkbox1ist runat="server" id="cbklist" >
</itemtemplate>
while selecting option1 i am not able to find control checkboxlist id.
$("[id*=chkOption1]").on("click", function () {
$.ajax({
type: "POST",
url: "AdminInitiateCollection.aspx/GetCollectionAreas",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
//alert(response.d);
}
});
});
function OnSuccess(response) {
var chkOption1 = $(this);
var grid = $(this).closest("table");
var dtcollection = response.d; // Here my output is [ hard disk, hello, collection ]
var ddCollection = dtcollection.split(",");
var $ctrls = $("#<%=gvInitiateCollection.ClientID%> tr input[id*='cbCollectFor']");
alert($ctrls);
for (var i = 0; i < ddCollection.length; i++) {
var isChecked = $("#<%=gvInitiateCollection.ClientID%> tr input[id*='chkOption1']").is(":checked");
if (isChecked) {
$ctrls.find('label:contains("' + ddCollection[i] + '")').prev().prop('checked', true);
} else {
$(this).removeAttr("checked");
$("td", $(this).closest("tr")).removeClass("selected");
$ctrls.find('label:contains("' + ddCollection[i] + '")').prev().prop('checked', false);
}
}
//});
}
What I have tried:
I am getting error from this line.
var $ctrls = $("#<%=gvInitiateCollection.ClientID%> tr input[id*='cbCollectFor']");
alert($ctrls);
("[id*=chkOption1]").on("click", function () {
.ajax({ type: "POST", url: "AdminInitiateCollection.aspx/GetCollectionAreas", data: '{}', contentType: "application/json; charset=utf-8", dataType: "json", success: OnSuccess, failure: function (response) { //alert(response.d); } }); }); function OnSuccess(response) { var chkOption1 =
(this); var grid =
这篇关于我无法在gridview jquery中找到checkboxlist id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!