Exemplo n.º 1
0
        public void UpdateRow <T>(T entry)
        {
            var row = Gridview.GetSelectedRows().FirstOrDefault();

            foreach (GridColumn col in Gridview.Columns)
            {
                var props = col.FieldName.Split('.');
                {
                    var propInfo = entry.GetType().GetProperty(props[0]);
                    if (propInfo != null)
                    {
                        var val = propInfo.GetValue(entry, null);
                        if (val != null)
                        {
                            for (var i = 1; i < props.Length; i++)
                            {
                                propInfo = val.GetType().GetProperty(props[i]);
                                val      = propInfo.GetValue(val, null);
                            }
                            Gridview.SetRowCellValue(row, col, val);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 public void UpdateRow <T>(int row, T obj) where T : class
 {
     foreach (GridColumn col in Gridview.Columns)
     {
         var props    = col.FieldName.Split('.');
         var propInfo = obj.GetType().GetProperty(props[0]);
         if (propInfo == null)
         {
             continue;
         }
         var val = propInfo.GetValue(obj, null);
         if (val == null)
         {
             continue;
         }
         for (var i = 1; i < props.Length; i++)
         {
             propInfo = val.GetType().GetProperty(props[i]);
             val      = propInfo.GetValue(val, null);
         }
         Gridview.SetRowCellValue(row, col, val);
     }
     Gridview.RefreshRow(row);
 }