How to append two field values in combobox display member in C#

后端 未结 7 672
死守一世寂寞
死守一世寂寞 2020-12-30 02:43

In my table, I have a field of firstname and lastname, now what I want is to set firstname and lastname as displaym

7条回答
  •  悲&欢浪女
    2020-12-30 03:25

    Your query should be like this in GetEmployees() function.

    "SELECT id,(lastname + ' ' + first_name) AS NAME FROM TABLE"
    
    cmbEmployees.DataSource = GetEmployees();
    cmbEmployees.DisplayMember = "NAME"; 
    cmbEmployees.ValueMember = "id";
    

提交回复
热议问题