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

[Solved] RadFormDecorator causing issues for dropdown grid column

6 Answers 113 Views
Grid
This is a migrated thread and some comments may be shown as answers.
J
Top achievements
Rank 1
J asked on 14 Mar 2013, 02:05 PM
See attached screenshot.

If I add the following to my page, the drop down for the Gender field gets styled but when I change it from Male to Female, it commits the row as Male (the default selected value); I can no longer select Female and have it save.  As soon as I remove the RadFormDecorator, everything works as desired but it loses the nicer display style.


<telerik:RadFormDecorator ID="rfdUIStyler" runat="server" DecoratedControls="All" />

<telerik:GridTemplateColumn HeaderText="Gender" SortExpression="Gender" UniqueName="Gender"
    DataField="Gender" FilterControlAltText="Filter Gender column" ColumnEditorID="cmbGridEdit_Gender"
    ShowSortIcon="False">
    <ItemTemplate>
        <%# DataBinder.Eval(Container.DataItem, "Gender") %></ItemTemplate>
    <EditItemTemplate>
        <asp:DropDownList ID="ddlGender" runat="server">
            <Items>
                <asp:ListItem Text="Female" Value="Female" />
                <asp:ListItem Text="Male" Value="Male" Selected="True" />
            </Items>
        </asp:DropDownList>
    </EditItemTemplate>
    <HeaderStyle Wrap="False" HorizontalAlign="Left" Width="80px" CssClass="grid-header" />
    <ItemStyle HorizontalAlign="Left" Width="90%" VerticalAlign="Top" />
</telerik:GridTemplateColumn>

protected void grdAthletes_ItemDataBound(object sender, GridItemEventArgs e)
{
    Control ddlGenderSelector = null;
    Control ctrlFieldEditor = null;
      Control dtDoBEditor = null;
 
    try
    {
        //Some controls don't load the values into the custom editor's automatically so force the values through
        if (e.Item.IsInEditMode)
        {
            ddlGenderSelector = e.Item.FindControl("ddlGender"); //Get the gender selection control
 
            //Load the current value for Gender into the column editor control
            if (ddlGenderSelector != null)
                ((DropDownList)ddlGenderSelector).SelectedValue = ((DataRowView)e.Item.DataItem)[6].ToString();
            //((RadDropDownList)ddlGenderSelector).SelectedValue = ((DataRowView)e.Item.DataItem)[6].ToString();
 
               dtDoBEditor = ((GridEditableItem)e.Item)[grdAthletes.MasterTableView.RenderColumns[7].UniqueName].Controls[0];
 
               if ((dtDoBEditor != null) && string.Compare(_sProgramCode, "Y", true) == 0)
               {
                    ((RadDatePicker)dtDoBEditor).SelectedDate = DateTime.Now.AddYears(-20);
                    ((RadDatePicker)dtDoBEditor).MinDate = DateTime.Now.AddYears(-20);
               }
 
            //Get the editor for the first field and set focus to it
            ctrlFieldEditor = ((GridEditableItem)e.Item)[grdAthletes.MasterTableView.RenderColumns[3].UniqueName].Controls[0];
 
            if (ctrlFieldEditor != null)
                ctrlFieldEditor.Focus();
        }
    }
    catch (Exception ex)
    {
        System.Diagnostics.Debug.Print("Error: " + ex.ToString());
        Exceptions.ProcessModuleLoadException(this, ex);
    }
}


I have tried using a Rad drop down instead but then I have issues loading the existing value (if Female is already selected, it still shows Male after edit no matter what I do).

Thanks.

6 Answers, 1 is accepted

Sort by
0
J
Top achievements
Rank 1
answered on 18 Mar 2013, 08:21 PM
Anyone?
0
Accepted
Galin
Telerik team
answered on 19 Mar 2013, 02:58 PM
Hello Juan,

I have tried your scenario, but it works as expected. For reference I am sending a sample page. Please check it out and let me know if I have missed something/


Greetings,
Galin
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.
0
J
Top achievements
Rank 1
answered on 19 Mar 2013, 03:07 PM
Same thing happens in your example.

Steps:

1) Click Edit on the first row.
2) Change Male to Female.
3) Click 'Update'

Column stays as Male.  :(  Attached are screenshots using your example project with no changes at all.
0
Galin
Telerik team
answered on 22 Mar 2013, 02:20 PM
Hi Juan,

The provided sample page has dummy data base and actually it does not upgrade the data. Therefore, this behavior is expected.

Could you please modify it, so the issue can be observed? This we will be able to test it locally and provide a proper solution.


Greetings,
Galin
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.
0
J
Top achievements
Rank 1
answered on 22 Mar 2013, 02:45 PM
Sure, I'll put that together for you shortly.
0
J
Top achievements
Rank 1
answered on 29 Mar 2013, 03:01 PM
I was putting together a sample project demonstrating the issue by copying my actual code into a new project and tweaking it so it doesn't need the databases and in doing so I was unable to reproduce the issue.  I then went back into my actual project and put the drop downs and form decorator back on and it worked correctly.

I've made a ton of changes to this project since the initial issue so perhaps one of the changes I made 'fixed' whatever was causing this to happen.

I wish I knew what was the actual cause so that I can avoid it in the future but since I cannot duplicate it now, I'll just have to wait and see if it ever happens again.

Thanks for all of your help.
Tags
Grid
Asked by
J
Top achievements
Rank 1
Answers by
J
Top achievements
Rank 1
Galin
Telerik team
Share this question
or