【发布时间】:2011-06-20 10:11:54
【问题描述】:
我已经检查了所有答案,但我的问题似乎不同 - 我有两组复选框列表。在启动时,我禁用了第二组中的所有复选框。
rotected void exchList_OnDataBound(object sender, EventArgs e)
{
for (int i = 0; i < exchList.Items.Count; i++)
{
exchList.Items[i].Attributes.Add("onclick", "gridCallback();");
exchList.Items[i].Enabled = false;
}//end for
}//end exchList_OnDataBound()
选中第一组中的一个框会启用另一个框。这是通过 jquery 完成的。
$('#<%= exchList.ClientID %> input:checkbox').each(function() {
$label = $(this).parent().children("label").text();
i = 0;
while(i < $jsonData.xxx.length)
{
if ($(this).attr('disabled'))
{
$(this).removeAttr('disabled');
$(this).attr('checked', 'checked');
}//end if
else
{
$(this).removeAttr('checked');
$(this).attr('disabled', 'disabled');
}//end else
i++;
}//end while
});
当这些框被选中时,在回调期间它不会被检测到。
protected void productGrid_OnCustomCallback(object sender,
DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e)
{
String markets = "", exchs = "";
int i;
for (i = 0; i < marketList.Items.Count; i++)
{
if (marketList.Items[i].Selected)
System.Diagnostics.Debug.WriteLine(marketList.Items[i].Text);
}//end for
for (i = 0; i < exchList.Items.Count; i++)
{
System.Diagnostics.Debug.WriteLine(exchList.Items[i].Text + " " + exchList.Items[i].Enabled);
}//end for
}//end productGrid_OnCustomCallback()
即使明确选中了复选框,它们也始终不会被选中。查看萤火虫表明,因为我禁用并启用了列表项,所以复选框由 DIV 封装,这可能是导致问题的原因。我在没有禁用/启用的情况下对其进行了测试,并且 HTML 没有围绕复选框的 DIV,现在它可以正常工作。如何从列表项中获取 DIV 内的复选框选中值?
【问题讨论】:
标签: jquery asp.net checkboxlist