Label.Text为空,但需要为值

时间:2019-05-23 20:49:54

标签: c# debugging

我得到的对象未设置为对象的实例,但我不知道为什么。我把布景弄对了吗?

KandidaatNamen的值为Sophie,但LabelKandidaatNaam的值为null。 LabelKandidaatNaam必须是Sophie的值。

Ukandidaten表格

 public string KandidaatNaam
    {
        set
        {
            KandidaatNamen = value;
            LabelKandidaatNaam.Text = KandidaatNamen;
        }
        get
        {
            return KandidaatNamen;
        }

    }

创建uPartijen

private void ButtonPartij_Click(object sender, EventArgs e)
    {
        Database con = new Database();

        if (_Form1.idPartijen.Contains(labelNummer.Text))
        {
            con.SqlQuery("SELECT * FROM `kandidaat` where `partijnummer` =@nummer ");
            con.Cmd.Parameters.Add("@nummer", MySql.Data.MySqlClient.MySqlDbType.VarString).Value = labelNummer.Text;

            Kandidatenlist = new List<uKandidaten>();
            idKandidaten = new List<string>();


            foreach (DataRow dr in con.QueryEx().Rows)
            {
                uKandidaten proitem = new uKandidaten(this);

                Voornaam = dr[2].ToString();
                Achternaam = dr[3].ToString();
                NummerKandidaat = dr[6].ToString();

                proitem.KandidaatNaam = Voornaam;
                proitem.KandidaatAchterNaam = Achternaam;
                proitem.KandidaatNummer = NummerKandidaat;


                Kandidatenlist.Add(proitem);


            }
            _Form1.panelPartijen.Controls.Clear();
            _Form1.panelPartijen.Controls.AddRange(Kandidatenlist.ToArray());

        }

See image

See image 2

0 个答案:

没有答案