I have this Grid in my c# application
The Display Value in column 1 has an ID and Description ( see screen below)
When i change values in column1 I want the description written into column2
I am trying to use LINQ and a LAMDA Expression . My script is as shown below
[private void dgvDetailsTable_CellValueC
hanged(obj
ect sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 1)
{
switch (this.dgvDetailsTable.Colu
mns[e.Colu
mnIndex].N
ame)
{
case "dgvcmbarsaleditemid":
var result = ((List<InventoryItemModel>
)dgvcmbars
aleditemid
.DataSourc
e).Find(x => x.INVITEMId.Equals(dgvcmba
rsaleditem
id.Selecte
d));
this.dgvDetailsTable.Curre
ntRow.Cell
s[2].Value
= result.INVITEMDescription;
break;
}
}
}[/code]
My database field name is INVITEMId and my DataGrid column 1 name is dgvcmbarsaleditemid.
In the debugger I can see that the 1188 records were selected and in the debugger i can see the loop search going on
See Debugger Screen below
At the end of the looping it can not find the selected record and put it in the result variable even though the selected record
is on screen and coming from the database. See Error screen below
![Error Screen with result variable having null]()
Whats wrong with my LAMDA expression and how can i correct it
Thanks for any assistance
Olukay
I found out the syntax isssue
Thanks