I hope I'm not too vague here and I'll be happy to post a project or just explain a bit better if required.
I have a simple grid with two columns. I am databinding the grid with NeedsDataSource, dynamically creating a DataTable in code-behind from a business object. I am trying to completely avoid using ObjectDataSources. In short:
Column1 = Entity.EmailAddress (example: abc@def.com)
Column2 = Entity.EmailAddressType.Description
EmailAddressType is an object of EmailAddressType with properties ID and Description. (example: hm=Home)
The grid simply allows someone to enter a number of email addresses, and what they're for: Home, Work, School, etc., with the type limited to a provided selection.
The ItemTemplate for column2 renders "Home". The EditItemTemplate presents a RadComboBox, also generated at runtime, with all EmailAddressTypes loaded with Value=type.ID and Text=type.Description.
At runtime, I can elect to Insert or Update, and the ComboBox renders the list. Everything looks good until changes are submitted.
The problem is that when I change the data and click Update, the RadGrid ItemUpdated event is fired, but only the first column with the address is available in the event e.Item. I thought the selected value from the second column EditItemTemplate would be available there too.
I don't think I'm properly defining the RadComboBox within the EditItemTemplate. Do I need to check the combobox itself to get the value? (Not sure it's available when ItemUpdated fires) How do I ensure that the value of the combobox is associated with the cells in the row being changed so that when postback events are fired the selected value comes back with all other data? (I haven't tried but I suspect I'm going to have the same problem with other controls, so what I learn here will be very helpful for subsequent work.
As to why I want to avoid ObjectDataSource: It's just too flaky, not powerful enough, always leaving something to be desired somewhere between markup and codebehind. Read notes by Nikhil Khotari, Manuel Abadia, and many others. So I'm trying to get some practice doing everything programmatically, and unfortunately sacrificing some of the designer benefits of binding to a datasource at design time.
Thanks!
I have a simple grid with two columns. I am databinding the grid with NeedsDataSource, dynamically creating a DataTable in code-behind from a business object. I am trying to completely avoid using ObjectDataSources. In short:
Column1 = Entity.EmailAddress (example: abc@def.com)
Column2 = Entity.EmailAddressType.Description
EmailAddressType is an object of EmailAddressType with properties ID and Description. (example: hm=Home)
The grid simply allows someone to enter a number of email addresses, and what they're for: Home, Work, School, etc., with the type limited to a provided selection.
The ItemTemplate for column2 renders "Home". The EditItemTemplate presents a RadComboBox, also generated at runtime, with all EmailAddressTypes loaded with Value=type.ID and Text=type.Description.
At runtime, I can elect to Insert or Update, and the ComboBox renders the list. Everything looks good until changes are submitted.
The problem is that when I change the data and click Update, the RadGrid ItemUpdated event is fired, but only the first column with the address is available in the event e.Item. I thought the selected value from the second column EditItemTemplate would be available there too.
I don't think I'm properly defining the RadComboBox within the EditItemTemplate. Do I need to check the combobox itself to get the value? (Not sure it's available when ItemUpdated fires) How do I ensure that the value of the combobox is associated with the cells in the row being changed so that when postback events are fired the selected value comes back with all other data? (I haven't tried but I suspect I'm going to have the same problem with other controls, so what I learn here will be very helpful for subsequent work.
As to why I want to avoid ObjectDataSource: It's just too flaky, not powerful enough, always leaving something to be desired somewhere between markup and codebehind. Read notes by Nikhil Khotari, Manuel Abadia, and many others. So I'm trying to get some practice doing everything programmatically, and unfortunately sacrificing some of the designer benefits of binding to a datasource at design time.
Thanks!