如何用js检查DropDownList有没有数据? DList.DataSource = ds
            DList.DataTextField = textt
            DList.DataValueField = valuee
            DList.DataBind()这样绑定数据之后,如何用javascript检测DropDownList有没有数据?

解决方案 »

  1.   

    if(document.getElementById("<%=DList.ClientID%>").options.length>0)
    {}
      

  2.   

    var ddlic = document.getElementById('DropDownList1').options.length;//选项个数
    if(ddlic<=0)
    {
    //没有
    }
      

  3.   


    function Check()
    {
        var i = document.getElementById("<%=DropDownList.ClientID%>").options.length;
        if(i>0)
        {
            alert("DropDownList里面选项不为空!");
        } 
         else
        {
            alert("DropDownList里面选项为空!");
        }
    }