Thank you for your response. It helped me to come up with a solution suited to my needs. (See code).
However, I noticed that if I selected a value in a combobox, then return to that cell, the previously selected value is not selected in the combobox. Can you advise how to achieve this?
Additionally, I am attempting to use a RadMaskedEditBoxEditor for the Attribute Types of numeric. Can you advise how I can set properties on the editor, such as MaskType, Mask, and PromptChar?
Private Sub gvBuildingData_EditorRequired(sender As Object, e As EditorRequiredEventArgs) Handles gvBuildingData.EditorRequired
If gvBuildingData.MasterTemplate.CurrentRow.Cells("AttributeTypeName").Value = "List of items" Then
e.EditorType = GetType(RadDropDownListEditor)
Else
e.EditorType = GetType(RadMaskedEditBoxEditor)
End If
End Sub
Private Sub gvBuildingData_CellEditorInitialized(sender As Object, e As GridViewCellEventArgs) Handles gvBuildingData.CellEditorInitialized
Dim WorkAreaAttributeID As Guid = Guid.Parse(gvBuildingData.MasterTemplate.CurrentRow.Cells("WorkAreaAttributeID").Value.ToString)
If e.Column.HeaderText.ToString.Contains("WA") And gvBuildingData.MasterTemplate.CurrentRow.Cells("AttributeTypeName").Value = "List of items" Then
Dim editor As RadDropDownListEditor = DirectCast(gvBuildingData.ActiveEditor, RadDropDownListEditor)
Dim editorElement As RadDropDownListEditorElement = DirectCast(editor.EditorElement, RadDropDownListEditorElement)
If gvBuildingData.MasterTemplate.CurrentRow.Cells("Attribute").Value = "Work Area Type" Then
dsWorkAreaTypes = _WorkAreaType_Select("Select_Active")
If dsWorkAreaTypes.Tables.Count > 0 Then
editorElement.DataSource = dsWorkAreaTypes.Tables(0)
editorElement.DisplayMember = "Name"
editorElement.ValueMember = "WorkAreaTypeID"
Else
' No work area type values exist
End If
Else
dsWorkAreaAttributeItems = _WorkAreaAttributeItem_Select("Select_All", WorkAreaAttributeID)
If dsWorkAreaAttributeItems.Tables.Count > 0 Then
editorElement.DataSource = dsWorkAreaAttributeItems.Tables(0)
editorElement.DisplayMember = "Item"
editorElement.ValueMember = "ItemID"
Else
' No work area attribute item values exist
End If
End If
editorElement.SelectedValue = Nothing
editorElement.SelectedValue = gvBuildingData.CurrentCell.Value
End If
End Sub
Private Sub gvBuildingData_CellFormatting(sender As Object, e As CellFormattingEventArgs) Handles gvBuildingData.CellFormatting
If e.Column.Name.Contains("WA") Then
If e.Row.Cells("AttributeTypeName").Value = "List of items" Then
If e.Row.Cells(e.Column.Name).Value IsNot Nothing Then
Dim cellValue As Guid = Guid.Parse(e.Row.Cells(e.Column.Name).Value)
Dim attribute As String = e.Row.Cells("Attribute").Value
e.CellElement.Text = _GetTextByValue(attribute, cellValue).ToString()
End If
End If
End If
End Sub
Private Function _GetTextByValue(attribute As String, cellValue As Guid) As Object
Select Case attribute
Case "Work Area Type"
For Each row As DataRow In dsWorkAreaTypes.Tables(0).Rows
If row("WorkAreaTypeID") = cellValue Then
Return row("Name").ToString()
End If
Next
Case Else
For Each row As DataRow In dsWorkAreaAttributeItems.Tables(0).Rows
If row("ItemID") = cellValue Then
Return row("Item").ToString()
End If
Next
End Select
Return String.Empty
End Function