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

Add New button (Insert mode) does not work

1 Answer 30 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jugoslav
Top achievements
Rank 1
Jugoslav asked on 01 Aug 2011, 09:45 PM
If i comment out the selectvalue portion it works and i am able to ADD NEW Item.
If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
            Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
 
            Dim Manufacturers As RadComboBox = CType(editedItem.FindControl("ManufacturerEdit"), RadComboBox)
            ProductsAccess.BindManufacturers(Manufacturers)
            'Dim Manufacturer As Integer = DataBinder.Eval(editedItem.DataItem, "Manufacturer").ToString
            'Manufacturers.SelectedValue = Manufacturer
 
            Dim Categories As RadComboBox = CType(editedItem.FindControl("CategoryEdit"), RadComboBox)
            ProductsAccess.BindCategories(Categories)
            'Dim Category As Integer = DataBinder.Eval(editedItem.DataItem, "Category").ToString
            'Categories.SelectedValue = Category

If i un-comment those lines i am only able to EDIT the items but when i click add new button it does nothing.
If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
            Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
 
            Dim Manufacturers As RadComboBox = CType(editedItem.FindControl("ManufacturerEdit"), RadComboBox)
            ProductsAccess.BindManufacturers(Manufacturers)
            Dim Manufacturer As Integer = DataBinder.Eval(editedItem.DataItem, "Manufacturer").ToString
            Manufacturers.SelectedValue = Manufacturer
 
            Dim Categories As RadComboBox = CType(editedItem.FindControl("CategoryEdit"), RadComboBox)
            ProductsAccess.BindCategories(Categories)
            Dim Category As Integer = DataBinder.Eval(editedItem.DataItem, "Category").ToString
            Categories.SelectedValue = Category

ProductsAccess.BindManufacturers(Manufacturers) is a pretty simple Sub that bind combobox to datatable. I even tried with iterating DataRows in the DataTable.Rows collection and populating the combo one by one. The problem persisted :(
THanks

1 Answer, 1 is accepted

Sort by
0
Jugoslav
Top achievements
Rank 1
answered on 01 Aug 2011, 10:03 PM
As soon as i changed the datatype of the dataitem used for SelectedValue it worked like a charm.

Dim Manufacturer As Integer
' changed to
Dim Manufacturer As String
' and it works as expected!!!
It's weird anyway. In my opinion it should cast the integer (late binding) but it does not. Why?

However please consider this thread as resolved. Thanks for reading!


Tags
Grid
Asked by
Jugoslav
Top achievements
Rank 1
Answers by
Jugoslav
Top achievements
Rank 1
Share this question
or