Exemple #1
0
        protected void GridView_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e)
        {
            StatusVM CloneItem = new StatusVM();

            if (bool.Parse(HttpContext.Current.Session["isCloneRow_Com"].ToString()) == true && GridView.FocusedRowIndex >= 0)
            {
                //List<int> selectedIds = GridView.GetSelectedFieldValues("Id").ConvertAll(id => (int)id);
                //CloneItem = StandardTypeProvider.GetSingleById(selectedIds.Last());

                CloneItem = Mapper.Map <StatusVM>(StatusProvider.GetSingleById(GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString()));


                HttpContext.Current.Session["isCloneRow_Com"] = false;

                PropertyInfo myFieldInfo;
                foreach (var myProperty in typeof(StatusVM).GetProperties())
                {
                    myFieldInfo = typeof(StatusVM).GetProperty(myProperty.Name);
                    if (myFieldInfo == null)
                    {
                        continue;
                    }
                    var ttt = myFieldInfo.GetValue(CloneItem);

                    e.NewValues[myProperty.Name] = myFieldInfo.GetValue(CloneItem);
                }
            }
        }