in

CodeSmith Community

Your Code. Your Way. Faster!

Winforms GridView and EditView Syncronizing?

Last post 03-13-2008 2:14 PM by jharmon@blinfo.com. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 03-11-2008 7:58 AM

    Winforms GridView and EditView Syncronizing?

    Would someone please give me guidance on how to implement the dataGridView along with a EditControl? 

    I have a dataGridView displaying records and when the user double-clicks the dataGridView I retrieve the Entity from the Service by UniqueId.  The question I have is how do I syncronize the dataGridView and the changes that are made within the EditControl.  Once the user presses save I want the dataGridView to display the changes and/or new records.

    • Post Points: 5
  • 03-13-2008 2:14 PM In reply to

    Re: Winforms GridView and EditView Syncronizing?

    OK, here is what I have done so far.  I am hoping that someone will let me know if I am on the right track or not.

    I have a table named Household and therefore NetTiers generated my service layer called HouseholdService.  What I am doing is allowing the user to define what data he/she wants and then they press a [Find] button.  Once the [Find] button is pressed I instantiate the approprate service (HouseholdService) and within the overrideable section of the HouseholdService I have the following code:

    private TList<Household> _HouseholdList;

    public TList<Household> HouseholdList
    {
    get { return _HouseholdList; }
    set { _HouseholdList = value; }
    }

    public void GetPagedList (String SqlWhereClause, String SqlFieldName, Int32 _RowStart, Int32 _BatchSize, out Int32 _RecordsFound)
    {
    _HouseholdList =
    this.GetPaged(SqlWhereClause, SqlFieldName, _RowStart, _BatchSize, out _RecordsFound);
    }

    So essentially I am storing the data that the datagridview and HouseholdEditControl can share.  Then in my main application I have the following code when the user presses [Find]:
    HouseholdService HouseholdService;  // this is in variable initialization

    // this is in [Find] button code: 
    if (HouseholdService == null) { HouseholdService = new HouseholdService(); }
    HouseholdService.GetPagedList(SqlWhereClause, SqlFieldName, _RowStart, _BatchSize, out _RecordsFound);
    grdData.DataSource = HouseholdService.HouseholdList;

    Then when the user signifies they want to update the record I have the following code in the HouseholdService overrideable section:
    Int32 iIndex = _HouseholdList.FindIndex(delegate(Household HouseholdEntity) { return HouseholdEntity.HouseholdId == entity.HouseholdId; });

    _HouseholdList[iIndex] = entity;

    return base.Update(entity);

    Can someone PLEASE respond and let me know if this is even close to being correct?  I am developing the framework and really do NOT want to go back and make a bunch of changes if this is not how things should be done.  Keep in mind I am new to Visual Studio and NETTIERS.

    • Post Points: 5
Page 1 of 1 (2 items)
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems