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

Dropdown items on External Edit form not binding.

2 Answers 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dustin Dodson
Top achievements
Rank 1
Dustin Dodson asked on 20 Dec 2012, 08:35 PM
Hello everyone,

This problem is killing me so I have to ask...

I have an external form that I am using pretty much just like the example shown here: Grid / Editing with External Form

Of course I have different fields. I have 3 dropdowns all of which have data items that are available/filtered by whats been selected in a previous control cascading.

So for example: Select DD1 -> DD2 fills -> Select DD2 -> DD3 fills.

Now if I am inserting something this works fine, but if I go straight to edit an item from the grid, then the values in the grid can't be found in the dropdowns. The dropdown controls can be found, but not the items as if they were not binding or firing the selectedValue_Changed event so that the list option values can get populated. However if I go to insert something first then try to edit anything it all works like it's supposed to.

I am using OpenAccessDataSource's for the dropdowns. they look something like this:

<telerik:OpenAccessLinqDataSource ID="oaldsMap" Runat="server"
        ContextTypeName="HRSystemModel.HRContext" EntityTypeName=""
        ResourceSetName="EMaps" Select="new (EMapName, ECaption)"
        Where="EProcedureName == @EProcedureName">
        <WhereParameters>
            <asp:ControlParameter ControlID="rtbProcedure" Name="EProcedureName"
                PropertyName="Text" Type="String" />
        </WhereParameters>
    </telerik:OpenAccessLinqDataSource>   
    <telerik:OpenAccessLinqDataSource ID="oaldsStage" Runat="server"
        ContextTypeName="HRSystemModel.HRContext" EntityTypeName="" OrderBy="ECaption"
        ResourceSetName="EStages" Select="new (EStageName,ECaption)"
        Where="EMapName == @EMapName">
        <WhereParameters>
            <asp:ControlParameter ControlID="cmbMapNames" DefaultValue="" Name="EMapName"
                PropertyName="SelectedValue" Type="String" />
        </WhereParameters>
    </telerik:OpenAccessLinqDataSource>
    <telerik:OpenAccessLinqDataSource ID="oaldsAction" Runat="server"
        ContextTypeName="HRSystemModel.HRContext" EntityTypeName=""
        ResourceSetName="EActions" Select="new (EActionName, ECaption)"
        Where="EStageName == @EStageName && EMapName == @EMapName">
        <WhereParameters>
            <asp:ControlParameter ControlID="cmbStageName" DefaultValue=""
                Name="EStageName" PropertyName="SelectedValue" Type="String" />
            <asp:ControlParameter ControlID="cmbMapNames" DefaultValue="" Name="EMapName"
                PropertyName="SelectedValue" Type="String" />
        </WhereParameters>
    </telerik:OpenAccessLinqDataSource>


So on the grids side of things. When I do the DisplayEditForm(GridDataItem selectedItem).... which looks like so:

protected void DisplayEditForm(GridDataItem selectedItem)
{
    PlaceHolder.FindControl("pnlExternalForm").Visible = true;
    (PlaceHolder.FindControl("btnSaveChanges") as Button).Text = "Update";
    (PlaceHolder.FindControl("cmbMapNames") as RadComboBox).FindItemByText(selectedItem["MMap"].Text).Selected = true;                       
    (PlaceHolder.FindControl("cmbStageName") as RadComboBox).FindItemByText(selectedItem["MStage"].Text).Selected = true;
    (PlaceHolder.FindControl("cmbAction") as RadComboBox).FindItemByText(selectedItem["MAction"].Text).Selected = true;
}

if I haven't displayed the external form before using insert for instance, it fails at PlaceHolder.FindControl("cmbMapNames"). Always.
It throws a need to create new object error... and I have checked to confirm that it's not the dropdown but the list item that it can't find.
 
Now after displaying the form via insert... even if I cancel and don't do the insert... just displaying it, when I come back to update or edit anything in the grid it works beautifully.

Someone please help before I throw my desktop out the window.

Thanks! :D

2 Answers, 1 is accepted

Sort by
0
Dustin Dodson
Top achievements
Rank 1
answered on 21 Dec 2012, 01:50 PM
Wow.... no responses at all??

Am I explaining this horribly or something? Because if I am just let me know... I'm kind of used to people asking me what the hell am I talking about... =D
0
Kostadin
Telerik team
answered on 26 Dec 2012, 09:01 AM
Hi Dustin,

I would suggest that you check out the following code library which demonstrates how to use the cascading RadComboBoxes into the RadGrid's edit item.

Kind regards,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Dustin Dodson
Top achievements
Rank 1
Answers by
Dustin Dodson
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or