What do I do wrong:
I got a entity like that:
Than I got a wizard that create new Adresse entity manually. The NouvAdresse is a public property located in my view model.
Like:
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:
When the entry is complete I got this code to add id in the Telephone collection of my Adresse Entity:
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?
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?