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

Add SubEntity problem

1 Answer 17 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Pierre
Top achievements
Rank 1
Pierre asked on 24 Aug 2010, 04:52 PM
What do I do wrong:

I got a entity like that:

public partial class Adresse
 {
     internal sealed class AdresseMetadata
     {
         // Metadata classes are not meant to be instantiated.
         private AdresseMetadata()
         {
         }
         public string Adresse1 { get; set; }
         public string GPS1 { get; set; }
         public string GPS2 { get; set; }
         public int ID { get; set; }
         [Include]
         [Association("Telephone", "ID", "AdresseID")]
         public EntityCollection<Telephone> Telephone { get; set; }
     }
 }

Than I got a wizard that create new Adresse entity manually. The NouvAdresse is a public property located in my view model.
Like:
NouvAdresse = new(Adresse);
NouvAdresse.GPS1 = "12345";
NouvAdresse.GPS2 = "12345";

At one step of the wizard, I got a RadGridView to add some phone number. The grid is binded with the public property NouvAdresse.Telephone
I got a button the do a RadGridTel.BeginInsert();
Then a codebiend function that instanciate an emptu phone entity:
private void GridTelephone_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
{
    Telephone Tel = new Telephone();
    Tel.TypeTelephoneID = 1;
    e.NewObject = Tel;
}

When the entry is complete I got this code to add id in the Telephone collection of my Adresse Entity:
private void GridTelephone_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
{
    if (e.EditedItem != null)
    {
        Telephone Tel = (Telephone)e.EditedItem;
        if (Tel.Numero != null && Tel.Numero.Length > 0)
        {
            m_wizAjouteAdresseVM.NouvAdresse.Telephone.Add((Telephone)e.EditedItem);
        }
    }
}

The row is added and visible to the grid. The Grid add automatically a new row with title "Click here to add new item". At this point if I click on this new row, or if I click on my custom add buton. The a new empty line appear and I can add my second phone number. But if I commit this line, the RowEditEnd is called and the new phone is added to the Adresse.Telephone collection. But this new line never show up in the Grid.

Any suggestion?

1 Answer, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 27 Aug 2010, 10:09 AM
Hello Pierre,

I cannot figure out what the problem is, according to the information everything seems to be correct.
Could you please send me a sample project which I can debug on my side, since this weird behavior sounds like a bug to me?
Thank you in advance.

Greetings,
Nedyalko Nikolov
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
Tags
GridView
Asked by
Pierre
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Share this question
or