How to save datagridview changes

Posts   
 
    
Posts: 18
Joined: 26-Jun-2006
# Posted on: 14-Jul-2006 17:33:00   

Hi,

Once I do changes on datagridview (update text column and add new row), changes are no save it. could you help or provied me any example. (Winform - C# - LLBLGen Version 2.0)

  ParmActionQuoteEntity _parmQuote = new ParmActionQuoteEntity();  
  private void frmParmAction_Load(object sender, EventArgs e)
    {

        this.dgvStatus1.DataSource = ParmActionQuoteEntity.GetParmActionCollection();
    }


    private void tsbSave_Click(object sender, EventArgs e)
    {
        _parmQuote.Save();      
    }

thanks,

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 14-Jul-2006 17:52:45   

You're fetching a collection with this code: this.dgvStatus1.DataSource = ParmActionQuoteEntity.GetParmActionCollection();

which you wrote yourself ? but you're saving another entity, _parmQuote.

You ofcourse have to save the collection (!) you fetched using GetParmActionCollection simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Posts: 18
Joined: 26-Jun-2006
# Posted on: 14-Jul-2006 21:39:27   

I see what you said, but I dont know what to do. there is not method to save a collection, sorry I just learning to use your tool and also C#

This is my code

    ParmActionQuoteEntity _parmQuote = new ParmActionQuoteEntity();

    public frmParmAction()
    {
        InitializeComponent();
    }
    private void frmParmAction_Load(object sender, EventArgs e)
    {

        this.dgvStatus1.DataSource = ParmActionQuoteEntity.GetParmActionCollection();

    }

   private void tsbSave_Click(object sender, EventArgs e)
    {

        _parmQuote.Save();  
    }



    public static ParmActionQuoteCollection GetParmActionCollection()
    {
        ISortExpression Sort = new SortExpression();
        Sort.Add(ParmActionQuoteFields.ActionName | SortOperator.Ascending);
        ParmActionQuoteCollection ParmAction = new ParmActionQuoteCollection();
        ParmAction.GetMulti(null, 0, Sort);
        return ParmAction;
    }

What I want is to retrieve all records from a table, display them on a DATAGRIDVIEW so end user can add or modified data and after save all data on table

Do you have a diferent idea how to do it, please help me I have tried hard.

Please could you provide me an example,

Thanks

cadolfo_2000 wrote:

Hi,

Once I do changes on datagridview (update text column and add new row), changes are no save it. could you help or provied me any example. (Winform - C# - LLBLGen Version 2.0)

  ParmActionQuoteEntity _parmQuote = new ParmActionQuoteEntity();  
  private void frmParmAction_Load(object sender, EventArgs e)
    {

        this.dgvStatus1.DataSource = ParmActionQuoteEntity.GetParmActionCollection();
    }


    private void tsbSave_Click(object sender, EventArgs e)
    {
        _parmQuote.Save();      
    }

thanks,

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 15-Jul-2006 21:12:44   

cadolfo_2000 wrote:

I see what you said, but I dont know what to do. there is not method to save a collection, sorry I just learning to use your tool and also C#

This is my code


        ParmActionQuoteEntity _parmQuote = new ParmActionQuoteEntity();

        public frmParmAction()
        {
            InitializeComponent();
        }
        private void frmParmAction_Load(object sender, EventArgs e)
        {

            this.dgvStatus1.DataSource = ParmActionQuoteEntity.GetParmActionCollection();

        }

       private void tsbSave_Click(object sender, EventArgs e)
        {

            _parmQuote.Save();  
        }



        public static ParmActionQuoteCollection GetParmActionCollection()
        {
            ISortExpression Sort = new SortExpression();
            Sort.Add(ParmActionQuoteFields.ActionName | SortOperator.Ascending);
            ParmActionQuoteCollection ParmAction = new ParmActionQuoteCollection();
            ParmAction.GetMulti(null, 0, Sort);
            return ParmAction;
        }

What I want is to retrieve all records from a table, display them on a DATAGRIDVIEW so end user can add or modified data and after save all data on table

Do you have a diferent idea how to do it, please help me I have tried hard.

Please could you provide me an example,

Thanks

Your GetParmActionCollection() returns a collection. That collection is bound to the grid, and that collection thus contains the entities which are changed when the user modifies data in the grid.

So if you want to save THAT data, as you do, change your routine to:


ParmActionQuoteCollection _boundData = null;

public frmParmAction()
{
    InitializeComponent();
}
private void frmParmAction_Load(object sender, EventArgs e)
{
    _boundData = ParmActionQuoteEntity.GetParmActionCollection();
    this.dgvStatus1.DataSource = _boundData;

}

private void tsbSave_Click(object sender, EventArgs e)
{
    _boundData.SaveMulti();
}

Frans Bouma | Lead developer LLBLGen Pro
Posts: 18
Joined: 26-Jun-2006
# Posted on: 16-Jul-2006 21:05:02   

Thank you very much, your advice solve the problem

have a nice day.

Otis wrote:

cadolfo_2000 wrote:

I see what you said, but I dont know what to do. there is not method to save a collection, sorry I just learning to use your tool and also C#

This is my code


        ParmActionQuoteEntity _parmQuote = new ParmActionQuoteEntity();

        public frmParmAction()
        {
            InitializeComponent();
        }
        private void frmParmAction_Load(object sender, EventArgs e)
        {

            this.dgvStatus1.DataSource = ParmActionQuoteEntity.GetParmActionCollection();

        }

       private void tsbSave_Click(object sender, EventArgs e)
        {

            _parmQuote.Save();  
        }



        public static ParmActionQuoteCollection GetParmActionCollection()
        {
            ISortExpression Sort = new SortExpression();
            Sort.Add(ParmActionQuoteFields.ActionName | SortOperator.Ascending);
            ParmActionQuoteCollection ParmAction = new ParmActionQuoteCollection();
            ParmAction.GetMulti(null, 0, Sort);
            return ParmAction;
        }

What I want is to retrieve all records from a table, display them on a DATAGRIDVIEW so end user can add or modified data and after save all data on table

Do you have a diferent idea how to do it, please help me I have tried hard.

Please could you provide me an example,

Thanks

Your GetParmActionCollection() returns a collection. That collection is bound to the grid, and that collection thus contains the entities which are changed when the user modifies data in the grid.

So if you want to save THAT data, as you do, change your routine to:


ParmActionQuoteCollection _boundData = null;

public frmParmAction()
{
    InitializeComponent();
}
private void frmParmAction_Load(object sender, EventArgs e)
{
    _boundData = ParmActionQuoteEntity.GetParmActionCollection();
    this.dgvStatus1.DataSource = _boundData;

}

private void tsbSave_Click(object sender, EventArgs e)
{
    _boundData.SaveMulti();
}