Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何设置所有数据';它在文本框中_C#_Sql_Linq - Fatal编程技术网

C# 如何设置所有数据';它在文本框中

C# 如何设置所有数据';它在文本框中,c#,sql,linq,C#,Sql,Linq,首先是一个搜索框表单和一个视图表单。在searchbox中传递id值后,它应该返回在textchange方法发生后与该人员id匹配的所有值。但它不会在文本框上显示一个值。这是我的密码 public void first_tab_search(string key) { key = txtSearch.Text; var first = from a in dbcon.personal_informations where a.la

首先是一个搜索框表单和一个视图表单。在searchbox中传递id值后,它应该返回在textchange方法发生后与该人员id匹配的所有值。但它不会在文本框上显示一个值。这是我的密码

 public void first_tab_search(string key)
        {
            key = txtSearch.Text;
            var first = from a in dbcon.personal_informations where a.last_name == key select a;
            foreach (var setThem in first)
            {
                txtsurname.Text = setThem.last_name;
                txtfirstname.Text = setThem.first_name;
                txtmiddlename.Text = setThem.middle_name;
                txtID.Text = setThem.userid;
                txtweight.Text = setThem.weight;
                txttin.Text = setThem.tin;
                txtsss.Text = setThem.sss;
                txtaeno.Text = setThem.agency_employee_no;
                txtbloodtype.Text = setThem.blood_type;
                txtcitizenship.Text = setThem.citizenship;
                txtcivilstatus.Text = setThem.civil_status;
                txtcpno.Text = setThem.cell_no;
                txtdob.Text = setThem.datetime_of_birth.ToString();
                txtemail.Text = setThem.email_address;
                txtgender.Text = setThem.sex;
                txtgsis.Text = setThem.gsis_id;
                txtheight.Text = setThem.height;
                txtnameext.Text = setThem.name_ext;
                txtpagibig.Text = setThem.pagibig_id;
                txtpermaaddr.Text = setThem.permanent_address;
                txtpermatelno.Text = setThem.permanent_telno;
                txtpermazip.Text = setThem.permanent_zipcode;
                txtphilhealth.Text = setThem.philhealth;
                txtpob.Text = setThem.place_of_birth;
                txtresidentialaddr.Text = setThem.residential_address;
                txtresitelno.Text = setThem.residential_telno;
                txtresizip.Text = setThem.residential_zipcode;
                txtweight.Text = setThem.weight;
            }
        }

你这里有很多问题

  • 将一个键传递给该方法,然后立即用搜索框的内容覆盖它

  • 您的搜索可能会返回多个结果,因此您的代码会在每个结果中循环,并用最后返回的行覆盖输出值。在循环中使用+=而不是+,即

    txtLastname.Text+=setThem.last_name

  • 您的代码当前区分大小写,这可能是理想的方法,但可能不是


  • 您是否尝试先调试它并查看
    中的值?顺便问一下,在循环中每次设置相同的文本框有什么意义?