Пример #1
0
        /// <summary>
        /// Update lookup code record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void HandleLookupUpdate(object sender, GridViewUpdateEventArgs e)
        {
            GridView    lkpCodeGrid = sender as GridView;
            GridViewRow updateRow   = lkpCodeGrid.Rows[e.RowIndex];

            // Fill dictionary from row controls
            CaisisGridView.ExtractCaisisInputValuesFromContainer(updateRow, e.NewValues);

            // Create a new biz for updating/inserting
            LookupCode biz = new LookupCode();
            // Determine if a lookupcodeid exists
            object lkpCodeIdKey = lkpCodeGrid.DataKeys[e.RowIndex][LookupCode.LookupCodeId];

            if (lkpCodeIdKey != null && !string.IsNullOrEmpty(lkpCodeIdKey.ToString()))
            {
                int lkpCodeId = int.Parse(lkpCodeIdKey.ToString());
                biz.Get(lkpCodeId);
            }
            else
            {
                return;
            }
            // Set the lkpcode extracted from textbox
            foreach (string col in e.NewValues.Keys)
            {
                //if (biz.HasColumn(col))
                if (biz.HasField(col))
                {
                    biz[col] = e.NewValues[col];
                }
            }

            biz.Save();

            // Notify the built-in update event to cancel/i.e., not bubble
            e.Cancel = true;
        }