This is a migrated thread and some comments may be shown as answers.

[Solved] Dynamically add GridDropDownColumn on DetailTable

1 Answer 205 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 24 Jun 2009, 08:07 PM
I need a dropdown list column with a different datasource for each detail table, so I am programmatically adding a new column to each DetailTable when it gets databound.  The column gets added but has no values in view/edit mode.  Any ideas why the following code fails to populate the values?

    Private Sub radgrid1_DetailTableDataBind(ByVal source As ObjectByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles radgrid1.DetailTableDataBind 
        If e.DetailTableView.Name = "DetailTable2" Then 
            Dim dropdownColumn As New Telerik.Web.UI.GridDropDownColumn() 
            dropdownColumn.HeaderText = "Test" 
            dropdownColumn.UniqueName = "dropdownColumn" 
            dropdownColumn.DropDownControlType = GridDropDownColumnControlType.DropDownList 
            e.DetailTableView.Columns.Insert(2, dropdownColumn) 
        End If 
    End Sub 
 
    Private Sub radgrid1_ItemCreated(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) Handles radgrid1.ItemCreated 
        If e.Item.OwnerTableView.Name = "DetailTable2" Then 
            If TypeOf e.Item Is GridEditableItem Then 
                Dim item As GridEditableItem = DirectCast(e.Item, GridEditableItem) 
                Dim dropdownColumn As GridDropDownColumn = DirectCast(item.OwnerTableView.Columns(2), GridDropDownColumn) 
 
                Dim data As New Dictionary(Of StringString
                data.Add("A""A"
                data.Add("B""B"
                dropdownColumn.FillValues(data, item) 
            End If 
        End If 
    End Sub 

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 29 Jun 2009, 03:48 PM
Hello Kevin,

To attain the functionality you are searching for, you need to bind the built-in GridDropDownColumn. For further information you can review this online demo.

Best wishes,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or