Exemplo n.º 1
0
        protected void PersonsGrid_InsertCommand(object sender, GridCommandEventArgs e)
        {
            if (e.Item is GridEditableItem)
            {
                GridEditableItem editedItem = e.Item as GridEditableItem;
                Hashtable        newValues  = new Hashtable();
                e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);

                if (!int.TryParse(newValues["Age"].ToString(), out int age))
                {
                    SetMessage("Age must be an Integer.");
                    return;
                }

                if (!int.TryParse(newValues["PersonTypeId"].ToString(), out int personType))
                {
                    SetMessage("Person Type must be an Integer.");
                    return;
                }

                Person person = new Person
                {
                    Name         = newValues["Name"].ToString(),
                    Age          = age,
                    PersonTypeId = personType
                };

                serviceClient.CreatePerson(person.Name, person.Age, person.PersonTypeId);
            }
        }