FineUI 官方论坛

标题: 下拉列表联动问题 [打印本页]

作者: の‵℡閊鳮﹌    时间: 2012-9-23 16:37
标题: 下拉列表联动问题
<ext:SimpleForm ID="SimpleForm1" Width="350px" runat="server" BodyPadding="5px" EnableBackgroundColor="true"
        Title="简单表单">
        <Items>
            <extropDownList ID="DropDownList1" Label="组别" ShowRedStar="true" CompareType="String"
                CompareValue="-1" CompareOperator="NotEqual" CompareMessage="请选择组别!" runat="server"
                AutoPostBack="true" OnSelectedIndexChanged="ddlSheng_SelectedIndexChanged">
            </extropDownList>
            <extropDownList ID="DropDownList2" Label="人员" ShowRedStar="true" CompareType="String"
                CompareValue="-1" CompareOperator="NotEqual" CompareMessage="请选择人员!" runat="server">
            </extropDownList>
        </Items>
    </ext:SimpleForm>

后台:
public void DownBind2()
    {
        //默认显示分类号为1的所有子类
        string dda = "";
        if (Session["u_qy"].ToString() == "1")
        {
            dda = "select * from tbType  where u_qy='1' order by u_team";
        }
        else if (Session["u_qy"].ToString() == "2")
        {
            dda = "select * from tbType  where  u_qy='2' order by u_team";
        }
        DataTable mytab = this.Get_Dt2(dda);
        //绑牢控件
        this.DropDownList1.DataSource = mytab;
        this.DropDownList1.DataValueField = "u_team";
        this.DropDownList1.DataTextField = "u_team";
        this.DropDownList1.DataBind();
        //添加一个空的首行
        this.DropDownList1.Items.Insert(0, new ListItem("=请选择组别=", "-1"));
    }


protected void ddlSheng_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (this.DropDownList1.SelectedValue != "-1")
        {
            string dda = "";
            if (Session["u_qy"].ToString() == "1")
            {
                if (Session["u_jn"].ToString() == "四区动感")
                {
                    dda = "select * from OT_user_table  where u_team='" + this.DropDownList1.SelectedValue + "' and u_jn='四区动感' and u_name!='" + Session["u_name"].ToString() + "' order by u_name ";
                }
                else if (Session["u_jn"].ToString() == "四区神")
                {
                    dda = "select * from OT_user_table  where u_team='" + this.DropDownList1.SelectedValue + "' and u_jn='四区神' and u_name!='" + Session["u_name"].ToString() + "' order by u_name ";
                }
                else if (Session["u_jn"].ToString() == "江湛动神" || Session["u_jn"].ToString() == "江湛神")
                {
                    dda = "select * from OT_user_table  where u_team='" + this.DropDownList1.SelectedValue + "' and  (u_jn='江湛动神' or u_jn='江湛神') and u_name!='" + Session["u_name"].ToString() + "' order by u_name";
                }
                else
                {
                    dda = "select * from OT_user_table  where u_team='" + this.DropDownList1.SelectedValue + "'  and u_jn='" + Session["u_jn"] + "' and u_name!='" + Session["u_name"].ToString() + "' order by u_name ";
                }
            }
            else if (Session["u_qy"].ToString() == "2")
            {
                string aaaa = Session["u_jn"].ToString();
                if (Session["u_jn"].ToString() == "复合全球通")
                {
                    dda = "select * from OT_user_table  where  u_team='" + this.DropDownList1.SelectedValue + "' and u_jn='复合全球通' and u_name!='" + Session["u_name"].ToString() + "' order by u_name ";
                }
                else if (Session["u_jn"].ToString() == "四区全球通")
                {
                    dda = "select * from OT_user_table  where u_team='" + this.DropDownList1.SelectedValue + "'  and u_jn='四区全球通' and u_name!='" + Session["u_name"].ToString() + "'  order by u_team,u_jn ";
                }
                else
                {
                    dda = "select * from OT_user_table  where  u_zg='2' and (u_qy='1' or u_qy='2') and u_team='" + this.DropDownList1.SelectedValue + "'  and u_jn='" + Session["jn"] + "' and u_name!='" + Session["u_name"].ToString() + "' order by u_team,u_jn ";
                }
            }
            this.DropDownList2.DataSource = Get_Dt(dda);
            this.DropDownList2.DataValueField = "u_Labor_number";
            this.DropDownList2.DataTextField = "u_name";
            this.DropDownList2.DataBind();
        }
    }

运行就弹窗提示Internal Server Error(500)

未将对象引用设置到对象的实例。 说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。

源错误:

执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。

堆栈跟踪:

[NullReferenceException: 未将对象引用设置到对象的实例。]   ExtAspNet.ControlBase.RecoverPropertiesFromJObject(JObject state) +667   ExtAspNet.ControlBase.OnInit(EventArgs e) +102   System.Web.UI.Control.InitRecursive(Control namingContainer) +321   System.Web.UI.Control.InitRecursive(Control namingContainer) +198   System.Web.UI.Control.InitRecursive(Control namingContainer) +198   System.Web.UI.Control.InitRecursive(Control namingContainer) +198   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +834


作者: wave.gui    时间: 2012-9-26 07:51
我遇到的问题跟你不一样,我是在DropDownList1.Items.Insert(0, new ListItem("-请选择-", "-1"));这个的时候报错,
作者: の‵℡閊鳮﹌    时间: 2012-9-26 19:19
wave.gui 发表于 2012-9-26 07:51
我遇到的问题跟你不一样,我是在DropDownList1.Items.Insert(0, new ListItem("-请选择-", "-1"));这个的 ...

你要写成DropDownList1.Items.Insert(0, new ExtAspNet.ListItem("-请选择-", "-1"));才可以。
作者: wave.gui    时间: 2012-9-27 01:10
哦,受教了。晕啊




欢迎光临 FineUI 官方论坛 (https://fineui.com/bbs/) Powered by Discuz! X3.4