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

CellBeginEdit comboElement DataSource Is Nothing for the First Time Only

1 Answer 60 Views
GridView
This is a migrated thread and some comments may be shown as answers.
JustinWong
Top achievements
Rank 1
JustinWong asked on 13 Sep 2010, 06:06 PM
Hi:

I have a strange problem that I could solve and it's driving me nuts!

I have dynamically added a Lookup column to my grid during form load:

    c = New GridViewLookUpColumn("ColFinalGrade_Manual", "FinalGrade_Manual")
    c.ValueMember = "GdRule_GradeCode"
    c.DisplayMember = "GdRule_GradeCode"
    c.DataSource = ds_Gd.Tables(0)
    RGV_StdEnrl.MasterGridViewTemplate.Columns.Insert(RGV_StdEnrl.Columns.Count - 1, c)

Then during CellBeginEdit of the grid, I have the following codes (except from longer codes)

    If RGV_StdEnrl.Columns(e.ColumnIndex).UniqueName = "ColFinalGrade_Manual" Then
        Dim editor As IInputEditor = Me.RGV_StdEnrl.ActiveEditor
        If Not editor Is Nothing AndAlso TypeOf (editor) Is RadComboBoxEditor Then
            Dim comboElement As RadComboBoxElement = CType(CType(editor, RadComboBoxEditor).EditorElement, RadComboBoxElement)
                            For I As Integer = 0 To comboElement.Items.Count - 1   (!!!!!PROBLEM IS HERE!!!!)
                                If comboElement.Items(I).Text = "" & RGV_StdEnrl.MasterGridViewTemplate.Rows(e.RowIndex).Cells("ColFinalGrade_Manual").Value Then
                                    comboElement.SelectedIndex = I
                                    Exit For
                                End If
                            Next
    . . .

The problem is:  The item count for comboElement is ALWAYS 0 when I click on that particular cell FOR THE FIRST TIME after the form is loaded. So, the correct value never gets selected.  In fact, during the FIRST run of CellBeginEdit, the DataSource for the comboElement is ALWAYS Nothing.  There is nothing I could do to change that. EVEN IF I first test for it begin nothing and then try to assign it a datasource at that time (If comboElement.DataSource Is Nothing Then comboElement.DataSource = theTable), the item count for the comboElement remains 0.  It almost as if it doesn't want to take anything. No error is generated either.

The strangest part is: This problem only happens ONCE every form load (the very first time that cell is click).  After that, the above code works exact as it should.

I'm just stumped, and would appreciate some help on this.

Thanks!

Justin

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 16 Sep 2010, 04:13 PM
Hello JustinWong,

You should use the CellEditorInitialized event instead.

It fires after the initialization of the editor's data source takes place, so your code should work. However, I noticed that you are not using our latest release. I would recommend trying the Q2 2010 SP2. You can downloads it from Your Account.

We will be glad to hear your feedback on the new release. If you need further assistance, please write me back.

Regards, Jack
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
JustinWong
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or