DataGrid problem - really need help

I have a datagrid, with a datatable as datasource.
I use this datagrid for editing.
In it I have a combobox column, and other types of columns.
When editing, the last row of my datagrid ( this is the big problem ), in one of my other columns (I am already in another column) I need the selected value from my comboboxcolumn, but i can't access it because the last row of my datatable, where this value should be, is not accesible.
I am using CurrentCellChanged to do that.
I tried dt.acceptchanges - doesn't work it delets this row.
any suggestion
thanks
[592 byte] By [tax] at [2007-12-16]
# 1
Please show code example of what you are doing.
DMan1 at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 2
Private Sub gridinreg_CurrentCellChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GridInreg.CurrentCellChanged
cel = GridInreg.CurrentCell
xv = x
yv = y
Try
If yv = 1 Then
CellValFin = colCmbG.Combo.Text
Else
CellValFin = GridInreg.Item(xv, yv).ToString
End If
Catch ex As Exception
CellValFin = ""
End Try
'if the final value in a cell has changed and is not nothing..
If CellValFin <> CellValInit And CellValFin <> "" Then
Try
Select Case yv
Case 2 'pe col cu CONT
'daca modif val contului
If Not ExistaCont(CellValFin, xv) Then
fer = New ConfirmAdd
fer.lbl.Text = "Contul " & CellValFin.ToUpper & _
" nu exista in planul de conturi !"
fer.txt.Text = CellValFin
fer.addNew = New AddCont
fer.vizlista = New PlanConturi
fer.ferCallerPlata = Me
DeschideFer(fer)
Exit Sub
End If
...

Private Function ExistaCont(ByVal cnt As String, ByVal rand As Integer) As Boolean
If rand <= dt.Rows.Count And Trim(cnt).Length >= 3 Then
ExistaCont = True
sql = "select cont, denumire, tip from PlanConturi where cont='" & cnt & "'"
rs = getdata(sql)
Try
If rs.EOF And rs.BOF Then
ExistaCont = False
rsClose(rs)
Else
Dim cont As String
cont = Trim(rs.Fields("Cont").Value)
If FolGestiuni Then
If SeparareContGest(cont) Then ' EsteContAnalitic Then
'daca este completata gestiunea caut contul in conturile inreg pt gestiuni
If (Not IsDBNull(GridInreg.Item(rand, 1))) AndAlso Trim(GridInreg.Item(rand, 1).ToString) <> "" Then 'AndAlso Trim(GridInreg.Item(rand, 1).ToString) <> "0" Then
'daca s-a completat gestiunea
GridInreg.Item(rand, 0) = rs.Fields("Denumire").Value 'recompletez numele
sql = "select * from gestiuni where g=" & dt.Rows(rand).Item("Gest")

'here is the problem: i try to use dt.Rows(rand).Item("Gest") but this row doesn't exit in the datatable, in this column i have a comboboxcolumn and the value that i need is in the datatable, in the datagrid i have the display value which is not what i need

rss = getdata(sql)
If Not (rss.EOF And rss.BOF) Then
GridInreg.Item(rand, 2) = cont + "_" + Trim(rss.Fields("id").Value)
End If
rsClose(rss)
Else
'nu s-a completat gest, spun ca nu se poate fol contul decat ca cont analitic
'se muta pe col gestiune
MsgBox("Contul poate fi folosit numai ca, cont analitic pentru gestiuni, " & _
vbCrLf & "Completati mai intai gestiunea!")
GridInreg.CurrentCell = New DataGridCell(rand, 1)
End If
Else
GridInreg.Item(rand, 0) = rs.Fields("denumire").Value
GridInreg.Item(rand, 2) = cont 'col cont
End If
Else
GridInreg.Item(rand, 0) = rs.Fields("denumire").Value
GridInreg.Item(rand, 2) = cont 'col cont
End If
rsClose(rs)
GridInreg.Item(rand, 3) = ""
GridInreg.Item(rand, 4) = ""
GridInreg.Item(rand, 5) = ""
GridInreg.Item(rand, 6) = SoldCont(cont, dtData.Value, cnn)
End If
Catch ex As Exception
End Try
End If
End Function
i can give u more detail if this is not enough
10x

tax at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 3
isn't there anyone who can give any suggestions?
tax at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified