我有一个LINQ来检索StationID和名称以绑定到comboBox,
var stationId = stationBll
.GetStations(true)
.Select(t => new {
StationID = t.StationID,
Name = t.Name })
.ToList();
cbMachine.DataSource = stationId;
cbMachine.DisplayMember = "Name";
cbMachine.ValueMember = "StationID";
因此,当我想从selectedValue()获取ID时,它将分配整个内容,例如{StationID:1,名称:xxxxxx} 如何仅获取StationID,而不能获取全部内容? 请看附件图片,谢谢!
var StationId = cbMachine.SelectedValue;