Add New button (Insert mode) does not work

2 posts, 0 answers
  1. Jugoslav
    Jugoslav avatar
    64 posts
    Member since:
    Mar 2011

    Posted 01 Aug 2011 Link to this post

    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
  2. Jugoslav
    Jugoslav avatar
    64 posts
    Member since:
    Mar 2011

    Posted 01 Aug 2011 Link to this post

    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!


  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top