The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Addnew() override

Last post 07-26-2007, 1:20 PM by David.Parsons. 5 replies.
Sort Posts: Previous Next
  •  07-23-2007, 4:42 PM 4047

    Addnew() override

     when i wish to set a value in a field of a new collection item, as below, how do i get the collection to accept the value like it would if I had  typed the value in a cell of the bound datagrid. The exapmle below will always correctly set the value of the field in the datagrid when I click a new line. and it add an item. But the row is not added complely until I add some value and validate the row in the grid. What do I need to do to have the addnew add a complete row that coul dbe saved without a manual cell validate event in the grid.
      
    Code:
    namespace BusinessObjects
    {
    	public partial class Component : esComponent
    	{
          
          
          public override void AddNew()
          {
             base.AddNew();
             int next_id = this.Collection.Count;
             this.SetColumn(BusinessObjects.ComponentMetadata.ColumnNames.AssemblyName,"Line " + next_id.ToString());
    
            
             
            
          }  
    	}

    Richard Young
  •  07-23-2007, 5:01 PM 4048 in reply to 4047

    Re: Addnew() override

    What version of ES are you on? After you call base.AddNew() everything should be done. What kind of problem are you having?

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  07-23-2007, 5:12 PM 4049 in reply to 4048

    Re: Addnew() override

    I using a Gridview control bound to a collection. I triggered the Addnew() by clicking on an empty row at the bottom. The Addnew() event fire and the line is added to the grid, but the grid in not updated, meaning that even though the column I have set the value of is visable, the row is not in a edited mode since the grid doesn't show the edit symbol at the row, and if a then save the collection, it recieve an error. But it a simply click in a cell on that row, enter a value and tab out of the cell the row is then in edited mode and a save will work. I am trying to get it so that a row added by clicking in the datagrid to add a new row will put a sequencial line number in a cell of the row and the row will be saveable with out any more user interaction.
     

    Richard Young
  •  07-24-2007, 4:12 AM 4052 in reply to 4049

    Re: Addnew() override

    What version of EntitySpaces are you using?
    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  07-24-2007, 6:31 AM 4055 in reply to 4052

    Re: Addnew() override

    2007.0.0709.0
    seem like i remember something like this with a long lost prior version
    Richard Young
  •  07-26-2007, 1:20 PM 4119 in reply to 4055

    Re: Addnew() override

    This should fire ListChanged:

    Code:
    base.AddNew();

    But, to fire PropertyChanged, you need to set the Property:

    Code:
    this.AssemblyName = "Line " + next_id.ToString());

    Not use SetColumn. Does that help?

     


    David Neal Parsons
    www.entityspaces.net
View as RSS news feed in XML