Completed
Last Updated: 23 Aug 2016 11:34 by ADMIN
ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 26 Sep 2014 10:39
Category: DataEntry and DataLayout
Type: Bug Report
2
FIX. RadDataEntry - incorrectly mapped value for the first item when using RadDropDownList as an editor
To reproduce: add a RadBindingNavigator and a RadDataEntry

Use the following code:

RadDropDownList ddl;
BindingSource bs;

public Form1()
{
    InitializeComponent();

    this.radDataEntry1.EditorInitializing += radDataEntry1_EditorInitializing;
    bs = new BindingSource();

    DataTable dt = new DataTable();
    dt.Columns.Add("ID", typeof(int));
    dt.Columns.Add("Description", typeof(string));
    dt.Columns.Add("Code1", typeof(string));
    dt.Columns.Add("Code2", typeof(string));
           
    dt.Rows.Add(1, "Description", "DE", "CD");
    dt.Rows.Add(2, "Description", "CD", "AB");
    dt.Rows.Add(3, "Description", "BC", "DE");
    bs.DataSource = dt;  
    this.radDataEntry1.DataSource = this.radBindingNavigator1.BindingSource = bs;
}

private void radDataEntry1_EditorInitializing(object sender, Telerik.WinControls.UI.EditorInitializingEventArgs e)
{
    if (e.Property.Name == "Code1" || e.Property.Name == "Code2")
    {
        ddl = new RadDropDownList();
        using (ProvinceCodesEntities dbContext = new ProvinceCodesEntities())
        {
            IEnumerable<ProvinceCode> codeList = dbContext.ProvinceCodes.ToList();

            ddl.DataSource = codeList;
            ddl.DisplayMember = "ProvinceCode1";
            ddl.ValueMember = "ProvinceCode1";
        }
        e.Editor = ddl;
    }
}

When you run the application, you will notice that only the first item in the collection has incorrect mapped values for the properties which use RadDropDownList as an editor. When navigating to the next items, the values are OK.

Workaround:

RadDropDownList ddl;
BindingSource bs;

public Form1()
{
    InitializeComponent();
    this.radDataEntry1.EditorInitializing += radDataEntry1_EditorInitializing;
    bs = new BindingSource();

    DataTable dt = new DataTable();
    dt.Columns.Add("ID", typeof(int));
    dt.Columns.Add("Description", typeof(string));
    dt.Columns.Add("Code1", typeof(string));
    dt.Columns.Add("Code2", typeof(string));
           
    dt.Rows.Add(1, "Description", "DE", "CD");
    dt.Rows.Add(2, "Description", "CD", "AB");
    dt.Rows.Add(3, "Description", "BC", "DE");
    bs.DataSource = dt;  
}

private void radDataEntry1_EditorInitializing(object sender, Telerik.WinControls.UI.EditorInitializingEventArgs e)
{
    if (e.Property.Name == "Code1" || e.Property.Name == "Code2")
    {
        ddl = new RadDropDownList();
        using (ProvinceCodesEntities dbContext = new ProvinceCodesEntities())
        {
            IEnumerable<ProvinceCode> codeList = dbContext.ProvinceCodes.ToList();
            
            ddl.DataSource = codeList;
            ddl.DisplayMember = "ProvinceCode1";
            ddl.ValueMember = "ProvinceCode1";
            ddl.Parent = this;
        }
        e.Editor = ddl;
    }
}

private void Form1_Load(object sender, EventArgs e)
{
    this.radDataEntry1.DataSource = this.radBindingNavigator1.BindingSource = bs;
}
4 comments
ADMIN
Dess | Tech Support Engineer, Sr.
Posted on: 11 Aug 2015 11:55
Hello Michael,

Thank you for writing back.

The suggested workaround does not include only specifying the RadDropDownList.Parent property in the RadDataEntry.EditorInitializing event, but also binding RadDataEntry in the Load event. Although, I have moved the code from the Form.Load event to the RadButton.Click event, the first record is mapped correctly after a dozens of clicks. It seems to behave as expected on my end with the latest version. Without reproducing the problem locally, we can make only conjectures what is causing the undesired behavior on your end. We kindly ask you to post your technical questions/problems in the support ticketing system (http://www.telerik.com/account/support-tickets/available-support-list.aspx) as this is the best way to reach our support staff - the support system assigns a response time for all of your questions, depending on your license and ensures that all questions will reach the respective developers, if needed. Alternatively, you can ask the community for help by posting your question in the online forums (http://www.telerik.com/community/forums.aspx). Note that most of the forum threads are reviewed by Telerik representatives and we address the questions asked by our customers in the forums as well.
Michael Hildebrand
Posted on: 07 Aug 2015 14:12
Hi Stefan - my trial version has run out and I can not submit any support tickets.  I am still using the trial DLLs to get a head start on development.  I am hoping to obtain a license in the next 2 weeks.

Is there any way I can see a work around or a fix, before I buy?
ADMIN
Stefan
Posted on: 07 Aug 2015 06:13
Hi Michael,

can you please submit a support ticket with the case information and our support team will help you find appropriate workaround if possible.

Thank you.
Michael Hildebrand
Posted on: 06 Aug 2015 18:23
I tried the work around above (i.e. ddl.Parent = this;) and it works 80% of the time.  

At 20% of the time the custom RadDropDownList control in the RadDataEntry form does not display the correct value.

You can test this by taking the code in the Load event and placing it in a button.  When you run the app, press the button 20 times (for good measure) and you will see the value incorrectly displayed in the DropDownList.

I'm at a point in my development that I need to get this fixed.  I'm using the trial version of Telerik WinForms, and plan on buying soon.  Please let me know if there is a fix for this! Thanks.