Jquery ASP.net复选框列表未获取选中值

Jquery ASP.net复选框列表未获取选中值,jquery,asp.net,checkboxlist,Jquery,Asp.net,Checkboxlist,我已经检查了所有的答案,但我的问题似乎不同-我有两套复选框列表。启动时,我禁用第二组中的所有复选框 rotected void exchList_OnDataBound(object sender, EventArgs e) { for (int i = 0; i < exchList.Items.Count; i++) { exchList.Items[i].Attributes.Add("onclick", "gridCallback();");

我已经检查了所有的答案,但我的问题似乎不同-我有两套复选框列表。启动时,我禁用第二组中的所有复选框

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()
受保护的void exchList\u OnDataBound(对象发送方,事件参数e)
{
对于(int i=0;i
选中第一组中的一个框将启用另一组中的框。这是通过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
    });
$('#输入:复选框')。每个(函数(){
$label=$(this.parent().children(“label”).text();
i=0;
而(i<$jsonData.xxx.length)
{
if($(this.attr('disabled'))
{
$(this.removeAttr('disabled');
$(this.attr('checked','checked');
}//如果结束
其他的
{
$(this.removeAttr('checked');
$(this.attr('disabled','disabled');
}//结束其他
i++;
}//结束时
});
当复选框处于选中状态时,在回调期间不会检测到该复选框

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()
受保护的void productGrid\u OnCustomCallback(对象发送方,
DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs(e)
{
字符串markets=“”,exchs=“”;
int i;
对于(i=0;i

即使复选框已明确选中,也始终不会选中它们。查看firebug可以发现,由于我禁用并启用了列表项,所以复选框被一个DIV封装,这可能是导致问题的原因。我在没有禁用/启用的情况下测试了它,HTML的复选框周围没有DIV,现在它可以正常工作了。如何从listitem中获取DIV中的复选框选中值?

如果我没记错,这是ASP.net控件的某种缺陷,如果在页面加载时禁用复选框,它总是返回为未选中状态,即使您在客户端启用并选中它。
解决方法是从服务器端发送启用的复选框,如果需要,在客户端加载时禁用它们


当然,最好的解决方案是完全不使用ASP.net控件,因为我发现它们过于复杂和过重。但,嘿,这只是我…

若我没记错的话,这是ASP.net控件的某种缺陷,若在页面加载时禁用复选框,它总是返回为未选中状态,即使您在客户端启用并选中了它。
解决方法是从服务器端发送启用的复选框,如果需要,在客户端加载时禁用它们


当然,最好的解决方案是完全不使用ASP.net控件,因为我发现它们过于复杂和过重。但是,嘿,那只是我…

试试我用checkboxlist使用的这些代码。它使用2页。没有jscript代码。。希望这有帮助。 第1页cs代码

Session["checkedarray"] = new string[] { "1.0", "2.0", "3.0" };
            {
                {
                    string[] checkedlist = new string[17];
                    int a = 0;

                    for (int i = 0; i <= 16; i++)
                    {
                        if (cblist1.Items[i].Selected == true)
                        {
                            checkedlist[a] = cbllist1.Items[i].ToString();
                            a = a + 1;
                        }
                    }

                    Session["checkedarray"] = checkedlist;
                    Session["numofchecked"] = a;
                    Response.Redirect("ReportPage2.aspx");
                }
            }
protected void Page_Load(object sender, EventArgs e)
{
    string[] arr = (string[])Session["checkedarray"];

    for (int i = 0; i < int.Parse(Session["numofchecked"].ToString()); i++)
    {
        ColcbList2.Items.Add(arr[i].ToString());
    }
}
Session[“checkedarray”]=新字符串[]{“1.0”、“2.0”、“3.0”};
{
{
string[]checkedlist=新字符串[17];
int a=0;

对于(inti=0;i请尝试我使用checkboxlist使用的这些代码。它使用2页。没有jscript代码。希望这对您有所帮助。 第1页cs代码

Session["checkedarray"] = new string[] { "1.0", "2.0", "3.0" };
            {
                {
                    string[] checkedlist = new string[17];
                    int a = 0;

                    for (int i = 0; i <= 16; i++)
                    {
                        if (cblist1.Items[i].Selected == true)
                        {
                            checkedlist[a] = cbllist1.Items[i].ToString();
                            a = a + 1;
                        }
                    }

                    Session["checkedarray"] = checkedlist;
                    Session["numofchecked"] = a;
                    Response.Redirect("ReportPage2.aspx");
                }
            }
protected void Page_Load(object sender, EventArgs e)
{
    string[] arr = (string[])Session["checkedarray"];

    for (int i = 0; i < int.Parse(Session["numofchecked"].ToString()); i++)
    {
        ColcbList2.Items.Add(arr[i].ToString());
    }
}
Session[“checkedarray”]=新字符串[]{“1.0”、“2.0”、“3.0”};
{
{
string[]checkedlist=新字符串[17];
int a=0;

对于(int i=0;i但是,如果不使用asp.net checkboxlist,我怎么能生成一个复选框列表呢?我不想使用javascript…好吧,如果你不想使用客户端代码在客户端生成控件,那么…是的,你几乎被服务器端控件卡住了:)。我个人使用了很多javascript(实际上是jQuery)它有许多比asp.net更简单、更易使用、更高效的控件。我建议你给它一个机会……但是,如果不使用asp.net checkboxlist,我怎么能生成复选框列表呢?我不想使用javascript……如果你不想使用客户端代码在客户端生成控件,那么……是的,你可以我个人使用了很多javascript(实际上是-jQuery),它有许多比asp.net更简单、更易使用、更高效的控件。我建议你给它一个机会。。。