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

e.Item.ExtractValues in InsertCommand returns null values

3 Answers 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 02 Dec 2008, 08:57 PM
Here is my code:
 Protected Sub RadGrid1_InsertCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.InsertCommand
        Dim insertItem As GridEditableItem = e.Item
        Dim dic As New System.Collections.Hashtable()
        insertItem.ExtractValues(dic)

        'Data Stuff goes here

        RadGrid1.Rebind()
    End Sub

But when looking at dic("SerialNo") (defined as a string) it has a value of Nothing, and when I look at the other two values (DropDown Columns, bound to int fields) they are set to 1

What would cause this to come back with the null value? And no matter what options I select in the dropdowns, the values always come in as 1.  What am I missing?

Thanks,

Steve




3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 03 Dec 2008, 11:14 AM
Hello Steven,

I tried to reproduce the mentioned issue but without avail. I attached the test project to this thread.
Let me know whether it's working as expected at your side.

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Steven
Top achievements
Rank 1
answered on 03 Dec 2008, 02:54 PM
Daniel, Thank you for your response to this. 

I continued to have the problem (your code did not).  So I was crafting a stripped down version of my code so you could run it and see the problem.  In stripping down my code, I found the bug.  It was a classic operator error.

For the benefit of anyone who may ever stumble across this thread, I will detail what my problem was.  My problem is that I also had an ItemCommand handler, to handle a custom command we have.

Unfortunately, OUTSIDE of the case-statement for the CommandNames in my ItemCommand I was doing a rebind. This clears all the changes before they get to the InsertCommand handler.

Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand       
        Select Case e.CommandName
            Case "DeleteAll"
                 '...   (Truncated For bevity )
        End Select
        RadGrid1.Rebind() '!!!! THIS LINE IS THE PROBLEM! It needs to only go inside the CaseStatements.
End Sub

So there you go.   Total doofus maneuver.

Thanks for your help.

Steve

0
Daniel
Telerik team
answered on 05 Dec 2008, 05:31 PM
Hello Steven,

Thank you for the explanation. I believe it will be helpful for our community.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Steven
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Steven
Top achievements
Rank 1
Share this question
or