示例#1
0
        protected void ddl_accesslevel_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddl_accesslevel.SelectedValue == "1001")
            {
                ddl_Company.DataSource = null;
                ddl_Company.DataBind();
                ddl_Company.Enabled = false;

                if (ddl_Company.SelectedItem != null && !string.IsNullOrEmpty(ddl_Company.SelectedItem.Text.ToString()))
                {
                    ddl_Company.SelectedItem.Text  = "";
                    ddl_Company.SelectedItem.Value = "";
                }
            }
            else
            {
                UsersHandler usersHandler = new UsersHandler();
                usersHandler.FillCompanyDllAction(Convert.ToInt32(ddl_accesslevel.SelectedValue));
                DataTable ddlData = usersHandler.dt;
                MessageCollection.copyFrom(usersHandler.MessageCollection);

                if (MessageCollection.isErrorOccured)
                {
                    MessageCollection.PublishLog();
                    lbl_err.Text    = MessageCollection.Messages[MessageCollection.Messages.Count - 1].ErrorMessage;
                    lbl_err.Visible = true;
                }
                else
                {
                    ddl_Company.DataSource     = ddlData;
                    ddl_Company.DataTextField  = "Name";
                    ddl_Company.DataValueField = "ID";
                    ddl_Company.DataBind();
                    ddl_Company.Enabled = true;

                    if (!string.IsNullOrEmpty(txt_pw.Text))
                    {
                        txt_pw.Attributes.Add("value", txt_pw.Text);
                    }
                }
                if (ddlData == null || ddlData.Rows.Count == 0)
                {
                    if (ddl_Company.SelectedItem != null && !string.IsNullOrEmpty(ddl_Company.SelectedItem.Text.ToString()))
                    {
                        ddl_Company.SelectedItem.Text  = "";
                        ddl_Company.SelectedItem.Value = "";
                        ddl_Company.Enabled            = false;
                    }
                }
            }
        }