Completed
Last Updated: 20 Jun 2016 06:47 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 21 Oct 2015 11:59
Category: GridView
Type: Bug Report
2
FIX. RadGridView - DataException "An entry with the same key already exists" when loading layout with calculated column
To reproduce:

public Form1()
{
    InitializeComponent();

    List<Item> items = new List<Item>();
    for (int i = 1; i <= 10; i++)
    {
        items.Add(new Item(i, "Product" + i, 0.25m * i, i));
    }
    this.radGridView1.DataSource = items;
    GridViewDecimalColumn col = new GridViewDecimalColumn("Calculated Column");             
    col.Expression = "Quantity*Price/100";
    this.radGridView1.Columns.Add(col);
    this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
}

public class Item
{
    public int Id { get; set; }

    public string Name { get; set; }

    public decimal Price { get; set; }

    public int Quantity { get; set; }

    public Item(int id, string name, decimal price, int quantity)
    {
        this.Id = id;
        this.Name = name;
        this.Price = price;
        this.Quantity = quantity;
    }
}

MemoryStream s = new MemoryStream();

private void radButton1_Click(object sender, EventArgs e)
{
    s = new MemoryStream();
    this.radGridView1.SaveLayout(s);
}

private void radButton2_Click(object sender, EventArgs e)
{
    this.radGridView1.LoadLayout(s);
}

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
    s.Close();
}


Workaround: before loading the layout, clear the columns
Attached Files:
2 comments
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 20 Jun 2016 06:47
Hello Ofer,

Thank you for writing.

I haven't succeeded in replicating the error when using an image column. That is why I have attached my sample project in the support ticket that you have opened on the same topic. Feel free to continue the communication there and provide a project demonstrating the problem. Thus, we would be able to investigate the precise case and assist you further. Thank you in advance.

Regards
Ofer Hadad
Posted on: 19 Jun 2016 06:23
Hi.

You're right, it really done repair.
But why for me it's still not good because I have a column type:  ImageColumn in the grid. 

So please please please take care of it as quickly as possible.

If there is a temporary solution, I'd love to hear.

Thanks.