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

GridDropDownColumn in Detail Table

3 Answers 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 23 Feb 2011, 09:14 PM
I've been trying to dynamically bind a list to the data source of a GridDropDownColumn in a detail table. I have manage to get it to mostly work, but it isn't binding the first row's cell. I've been using the code below in various radGrid1 subs, and I keep getting the same results. I believe that I'm binding the data source after the first row is created and bound, but where do i put it so I can bind the data source before the first one.

Thanks for any help.

If (e.Item.OwnerTableView.Name = "DetailTable") Then
 
    If _list Is Nothing Then
        _list = Managers.DataManager.LoadAll
    End If
 
    'set the data sourse
    If TypeOf e.Item Is GridDataItem Then
 
        If Not _IsBound Then
            Dim item As GridDropDownColumn = TryCast(e.Item.OwnerTableView.GetColumnSafe("ddcCondition"), GridDropDownColumn)
            Dim itemManager As GridDropDownColumnEditor = TryCast(item.ColumnEditor, GridDropDownColumnEditor)
            itemManager.DataSource = _list
            itemManager.DataBind()
            _IsBound = True
        End If
    End If
End If

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Feb 2011, 09:19 AM
Hello James,

In which event you have tried to bind the GridDropDownColumn?. Try to bind it inside RadGrid's ItemCreatedEvent and check whether it works now.

VB.Net:
Protected Sub RadGrid1_ItemCreated(sender As Object, e As GridItemEventArgs)
    If TypeOf e.Item Is GridDataItem AndAlso e.Item.OwnerTableView.Name = "DetailTable" Then
        Dim item As GridDropDownColumn = TryCast(e.Item.OwnerTableView.GetColumnSafe("ddcCondition"), GridDropDownColumn)
        Dim itemManager As GridDropDownColumnEditor = TryCast(item.ColumnEditor, GridDropDownColumnEditor)
        itemManager.DataSource = _list
        itemManager.DataBind()
        _IsBound = True
    End If
End Sub


Thanks,
Princy.
0
James
Top achievements
Rank 1
answered on 24 Feb 2011, 03:07 PM
I've tried RadGrid1_ItemDataBound and RadGrid1_ItemCreated with the same results (not binding the first cell), and I also tried RadGrid1_DetailTableDataBind and that just plain didn't work.
0
Vasil
Telerik team
answered on 01 Mar 2011, 05:02 PM
Hello James,

I also tried Princy's solution and it works nice here. I am attaching it in a sample project.

All the best,
Vasil
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Grid
Asked by
James
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
James
Top achievements
Rank 1
Vasil
Telerik team
Share this question
or