I use:
- MS SQL Server 2014 database;
- Entity Framework.
I am using GridControl with an "empty row" element.
The user is trying to add a new entry in the GridControl.
After adding a new record does not update the field, which is formed by the database.
In my case, this field is "ID".
It can also be other fields that the database forms.
The "ID" field is updated only after the new record is being edited.
Question.
How to make the field that is filled with the database updated in the GridControl after adding a new entry in the GridControl?
namespace Rsh.frm.frm3.Core.ModelEFFrm_3
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public partial class PrbEntitiesF3 : DbContext
{
public PrbEntitiesF3()
: base("name=PrbEntitiesF3")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<tbl_930_3_2_Test> tbl_930_3_2_Test { get; set; }
}
}
namespace Rsh.frm.frm3.Core.ModelEFFrm_3
{
using System;
using System.Collections.Generic;
public partial class tbl_930_3_2_Test
{
public int Id { get; set; }
public string Text { get; set; }
}
}
public partial class Frm3UC : UserControl
{
PrbEntitiesF3 entiF3;
public Frm3UC()
{
InitializeComponent();
entiF3 = new PrbEntitiesF3();
}
public void FillGrid3()
{
entiF3.tbl_930_3_2_Test.Load();
bs3.DataSource = entiF3.tbl_930_3_2_Test.Local.ToBindingList();
gridControl3.DataSource = bs3;
}
public void Save()
{
entiF3.SaveChanges();
}
}
Update_1
I want to make the logic work:
1. User filled the field.
The code (or standard tools "devexpress") adds a new entry to the Grid.
The code (or standard tools "devexpress") saves an entry to the database.
The solution is to handle the GridView_FocusedRowChanged event.
Please see the following screencast: