I have custom objects of type phone and each phone has a phonetype example Phone.PhoneType.Name="Business"
I have a grid which is bound to a generic list of Phone. One of the columns in the grid is a GridViewLookupColumn named phonetype (ie. Business, Mobile, Fax etc..)
On the init of my app I assign the PhoneTypes to the data source
Me
.PhoneTypeBindingSource.DataSource = CMXApplication.LookUps.PhoneTypes
CType(Me.PhonesRadGridView.Columns("PhoneType"), Telerik.WinControls.UI.GridViewLookUpColumn).DataSource = Me.PhoneTypeBindingSource.DataSource
Because of the nature of the custom objects I intercept the Cellformatting event, to display the name of the phone type
Private Sub PhonesRadGridView_CellFormatting(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles PhonesRadGridView.CellFormatting
If e.CellElement.RowIndex >= 0 Then
If e.CellElement.ColumnIndex = 1 Then
e.CellElement.Text =
CType(PhonesBindingSource(e.CellElement.RowIndex), FTS.CMX.CMXModel.Phone).PhoneType.Name
End If
End If
End Sub
so far so good. When I edit the grid row I select a different phonetype in my GridViewLookUpColumn (PhoneType). I need to assign a phonetype from the GridViewLookUpColumn to my phone. What I think I need to do is this, capture the CellEndEdit value from the GridViewLookUpColumn and assign a phonetype to my phone.
When I query the GridViewLookUpColumn it is not the selected value from my grid
Can you give me pointers on how to achieve the desired results?
Private Sub PhonesRadGridView_CellEndEdit(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles PhonesRadGridView.CellEndEdit
Dim Phone As FTS.CMX.CMXModel.Phone = ContactProxy.Contact.Phones(PhonesRadGridView.CurrentRow.ViewInfo.CurrentIndex)
If PhonesRadGridView.CurrentRow.Cells(0).Value = String.Empty Then
If Phone.EntityState = EntityState.Added Then
PhonesRadGridView.Rows.RemoveAt(ContactProxy.Contact.Phones.Count - 1)
ContactProxy.Contact.Phones.Remove(Phone)
End If
Else
If e.ColumnIndex = 1 Then 'assign the phone type to the phone
'CType(Me.PhonesRadGridView.CurrentCell, Telerik.WinControls.UI.GridComboBoxCellElement).Text
Debug.WriteLine(
CType(Me.PhonesRadGridView.CurrentCell, Telerik.WinControls.UI.GridComboBoxCellElement).Value)
End If
End If
End Sub
Thanks P