protected void GridView_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e) { CompanyVM CloneItem = new CompanyVM(); if (bool.Parse(HttpContext.Current.Session["isCloneRow_Com"].ToString()) == true && GridView.FocusedRowIndex >= 0) { //List<int> selectedIds = GridView.GetSelectedFieldValues("Id").ConvertAll(id => (int)id); //CloneItem = CompanyProvider.GetSingleById(selectedIds.Last()); CloneItem = Mapper.Map <CompanyVM>(CompanyProvider.GetSingleById(GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString())); HttpContext.Current.Session["isCloneRow_Com"] = false; PropertyInfo myFieldInfo; foreach (var myProperty in typeof(CompanyVM).GetProperties()) { myFieldInfo = typeof(CompanyVM).GetProperty(myProperty.Name); if (myFieldInfo == null) { continue; } var ttt = myFieldInfo.GetValue(CloneItem); e.NewValues[myProperty.Name] = myFieldInfo.GetValue(CloneItem); } } }
IEnumerable <CompanyVM> GetData(string ID) { CompanyVM item = Mapper.Map <CompanyVM>(CompanyProvider.GetSingleById(ID)); List <CompanyVM> ItemList = new List <CompanyVM>(); if (item != null) { ItemList.Add(item); } return(ItemList); }
protected void GridView_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e) { CompanyVM CloneItem = new CompanyVM(); if (CloneKey == true) { List <string> selectedIds = GridView.GetSelectedFieldValues("CompanyID").ConvertAll(x => x.ToString()); CloneItem = Mapper.Map <CompanyVM>(CompanyProvider.GetSingleById(selectedIds.Last())); CloneKey = false; } PropertyInfo myFieldInfo; foreach (var myProperty in typeof(CompanyVM).GetProperties()) { myFieldInfo = typeof(CompanyVM).GetProperty(myProperty.Name); if (myFieldInfo == null) { continue; } var ttt = myFieldInfo.GetValue(CloneItem); e.NewValues[myProperty.Name] = myFieldInfo.GetValue(CloneItem); } }