4

i'm newbie in devexpress. when i add new row and fill some value to one cell, then i focus to other cell in same row i lost value in that cell. This is my code (column name in gridview match with coumn in Datatable dtGroupRole)

FrmUser.cs
...
adminGroupRoles = AdminGroupRoles.GetAllGroupRoles().ToList();
dtGroupRole = GlobalVars.ToDataTable<AdminGroupRoles>(adminGroupRoles);
grdGroupRoles.DataSource = adminGroupRoles;


AdminGroupRoles.cs
public class AdminGroupRoles
{
    public int GroupId { get; set; }
    public string GroupName { get; set; }

    public static List<AdminGroupRoles> GetAllGroupRoles()
    {
        return AdminGroupRoles.Inst.ExeStoreToList("sp_AdminUsers_GetAllGroupRoles");
    }
}

The edited cell was reset:

Edited cell was reset

Thanks all :)

alistaire
  • 42,459
  • 4
  • 77
  • 117

2 Answers2

0

I see that you assign adminGroupRoles as the grid source. It's a List. So that the grid can add new rows, the data source should be IBindingList. adminGroupRoles doesn't implement it. As far as I understand, dtGroupRole is DataTable converted from adminGroupRoles. So, you need to use as the grid data source:

adminGroupRoles = AdminGroupRoles.GetAllGroupRoles().ToList();
dtGroupRole = GlobalVars.ToDataTable<AdminGroupRoles>(adminGroupRoles);
grdGroupRoles.DataSource = dtGroupRole;
Gosha_Fighten
  • 3,838
  • 1
  • 20
  • 31
0

Use BindingList instead of List as Gosha_Fighten replied. Then you can convert your bindinglist to list like:
List <T> list = yourbindinglist.Select(b => b).ToList();
OR
convert your list<T> to bindinglist<T> like:
yourBindingList = new BindingList<T>(listToConvert);

bini teshome
  • 1
  • 1
  • 2