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

ObjectDataSource bound RadComboBox inside RadGrid

6 Answers 252 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 28 Jun 2010, 10:39 PM
I have a EditFormSettings FormTemplate inside a RadGrid that contains two comboboxes:
(Looks something like this):
<FormTemplate> 
                    <table> 
                        <tr> 
                            <td> 
                                Inventory Name: 
                            </td> 
                            <td> 
                                <telerik:RadComboBox SelectedValue='<%# Bind( "InventoryId") %>' ID="RadComboBoxInventoryName" runat="server" Height="300px" Width="300px" 
                                    Filter="Contains" MarkFirstMatch="true" ChangeTextOnKeyBoardNavigation="false" 
                                    DataSourceID="ObjectDataSourceInventoryName" DataTextField="Name" DataValueField="InventoryId" AutoPostBack="true"
                                    <Items> 
                                        <telerik:RadComboBoxItem Text="" Value="" Selected="true" /> 
                                    </Items> 
                                </telerik:RadComboBox> 
                            </td> 
                        </tr> 
                        </tr> 
                            <tr> 
                            <td> 
                                Attribute: 
                            </td> 
                            <td> 
                                <telerik:RadComboBox Text='<%# Bind( "Attribute") %>' ID="RadComboBoxAttribute" runat="server" Height="300px" Width="300px" 
                                    Filter="Contains" MarkFirstMatch="true" ChangeTextOnKeyBoardNavigation="false" 
                                    DataSourceID="ObjectDataSourceAttribute" DataTextField="Attribute" DataValueField="Attribute" AutoPostBack="true"
                                    <Items> 
                                        <telerik:RadComboBoxItem Text="" Value="" Selected="true" /> 
                                    </Items> 
                                    <ItemTemplate> 
                                        <%# DataBinder.Eval(Container.DataItem, "Type")%>.<%# DataBinder.Eval(Container.DataItem, "Attribute")%> 
                                    </ItemTemplate> 
                                </telerik:RadComboBox> 
                            </td> 
                        </tr> 
                        <tr> 
                            <td align="left" colspan="2"
                                <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' 
                                    runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'
                                </asp:Button>&nbsp; 
                                <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" 
                                CommandName="Cancel"></asp:Button></td
                        </tr> 
                    </table> 
                </FormTemplate> 
Simple enough... There are two RadComboBoxes with two different ObjectDataSources applied. The ObjectDataSources look like this:
    <asp:ObjectDataSource ID="ObjectDataSourceInventoryName" runat="server"  
        TypeName="Ams.Web.BackOffice.InventoryAdapter"  
        DataObjectTypeName="Ams.Core.DomainObject.Inventory"  
        OldValuesParameterFormatString="original_{0}" 
        ConflictDetection="CompareAllValues" 
        SelectMethod="GetInventoryForComboBox"
     </asp:ObjectDataSource> 
 
    <asp:ObjectDataSource ID="ObjectDataSourceAttribute" runat="server"  
        TypeName="Ams.Web.BackOffice.InventoryTypeAttributesAdapter"  
        DataObjectTypeName="Ams.Core.DomainObject.InventoryAttribute_InventoryType"  
        OldValuesParameterFormatString="original_{0}" 
        ConflictDetection="CompareAllValues"  
        SelectMethod="GetAttributeByInventoryId"
<SELECTPARAMETERS> 
                <asp:ControlParameter Name="aInventoryId" PropertyName="SelectedValue" ControlID="RadComboBoxInventoryName" /> 
            </SELECTPARAMETERS> 
     </asp:ObjectDataSource> 
             

Note, the ObjectDataSource of interest is the second, as it has a dependency on the first for one of its SelectParameters. When the page loads, I get an error stating:

Could not find control 'RadComboBoxInventoryName' in ControlParameter 'aInventoryId'.

Basically, it reports that it cannot find the control for the aInventoryId parameter (as its not rendered on the page yet).
Is it possible to use ObjectDataSources with parameter dependencies inside an edit form? If not, is there a work around?
Thanks in advance,
Tim
PS. I've tried the $ sign trick some other have posted.. No dice. (Inspected the client "name" attribute for the input control of the RadComboBox --

ctl00$ContentPlaceHolderBody$mImportMappingGrids$RadGridOrigin$ctl00$ctl07$RadComboBoxInventoryName

Nope...

6 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 30 Jun 2010, 08:09 AM
Hello Tim,

Can you move the DataSources inside the EditForm template and see if this helps?

Sincerely yours,
Rosen
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
0
Tim
Top achievements
Rank 1
answered on 01 Jul 2010, 04:09 PM
Did not work -- A control with ID "ObjectDataSource*" could not be found.
0
Accepted
Rosen
Telerik team
answered on 01 Jul 2010, 05:05 PM
Hello Tim,

You should place the DataSourceControls before the controls to which they are attached.

Sincerely yours,
Rosen
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
0
Tim
Top achievements
Rank 1
answered on 01 Jul 2010, 06:34 PM
Fantastic!
Just to clarify. The ObjectDataSource must be inside the <FormTemplate> tag, but *BEFORE* the actual control referencing it.
(I tried n - 1 configurations before posting on the forum, the suggestion being the '1').
Thanks!
Tim
0
David
Top achievements
Rank 1
answered on 20 Jul 2011, 04:57 PM
Hello,

I have a similar scenario: 2 radcomboboxes, second depending on value of the first, both bound to different datasources.

The only trouble is, my radcomboboxes are in GridDataItems, not the FormTemplate. Additionally, I want to have an autocomplete of sorts, similar to how it appears in the following demo:

http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/filteringcombo/defaultvb.aspx

Is this even possible?

Thanks,

David
0
Dimitar Terziev
Telerik team
answered on 22 Jul 2011, 03:31 PM
Hello David,

There is a code library  here, which you could use as a reference point in order to implement your scenario.

Kind regards,
Dimitar Terziev
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Grid
Asked by
Tim
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Tim
Top achievements
Rank 1
David
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Share this question
or