asp.net前台用js实现datagrid中radiobutton单选不起作用 100
js:functionSetRadioButtonState(){vardom=document.all;varel=event.srcElement;if(el.tag...
js:
function SetRadioButtonState() {
var dom = document.all;
var el = event.srcElement;
if (el.tagName == "INPUT" && el.type.toLowerCase() == "radio") {
for (i = 0; i < dom.length; i++) {
if (dom[i].tagName == "INPUT" && dom[i].type.toLowerCase() == "radio" && dom[i].name.toLowerCase() != "radiobuttonlisttype") {
dom[i].checked = false;
}
}
}
el.checked = !el.checked;
}
后台;
private void DataGridSchedule_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemIndex < 0)
{
return;
}
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
System.Web.UI.WebControls.RadioButton RadioButtonSelection;
RadioButtonSelection = (RadioButton)e.Item.FindControl("RadioButtonSelection");
RadioButtonSelection.Attributes.Add("OnClick", "SetRadioButtonState()");
}
} 展开
function SetRadioButtonState() {
var dom = document.all;
var el = event.srcElement;
if (el.tagName == "INPUT" && el.type.toLowerCase() == "radio") {
for (i = 0; i < dom.length; i++) {
if (dom[i].tagName == "INPUT" && dom[i].type.toLowerCase() == "radio" && dom[i].name.toLowerCase() != "radiobuttonlisttype") {
dom[i].checked = false;
}
}
}
el.checked = !el.checked;
}
后台;
private void DataGridSchedule_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemIndex < 0)
{
return;
}
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
System.Web.UI.WebControls.RadioButton RadioButtonSelection;
RadioButtonSelection = (RadioButton)e.Item.FindControl("RadioButtonSelection");
RadioButtonSelection.Attributes.Add("OnClick", "SetRadioButtonState()");
}
} 展开
展开全部
$(document).ready(function() {
$("#ctl00_ContentPlaceHolder1_dgRides input").click(function() {
this.c = 1;
var ck = this.checked;
$("#dgRides input").each(function() {
if (this.c != 1) {
this.checked = false;
}
});
this.c = 0;
});
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询