Beispiel #1
0
        void GetGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.ToLower() == "add")
            {
                GridViewRow row = (e.CommandSource as Control).Parent.Parent as GridViewRow;
                Hashtable   htd = new Hashtable();

                foreach (TemplateField tf in GridViewManager1.GridView.Columns)
                {
                    GenericItem item = tf.FooterTemplate as GenericItem;
                    if (item == null)
                    {
                        continue;
                    }
                    try
                    {
                        foreach (DictionaryEntry de in item.ExtractValues(row))
                        {
                            htd.Add(de.Key, de.Value);
                        }
                    }
                    catch (Exception ex)
                    {
                        Exceptions.Logger.Error(ex);
                        HtmlHelper.Alert(ex.Message, Page);
                        return;
                    }
                }

                try
                {
                    AdminUserController ctrl = new AdminUserController();
                    AdminUserInfo       info = new AdminUserInfo();
                    foreach (System.Reflection.PropertyInfo property in CBO.GetPropertyInfo(typeof(AdminUserInfo)))
                    {
                        if (htd[property.Name] != null)
                        {
                            property.SetValue(info, htd[property.Name], null);
                        }
                    }
                    ctrl.InsertAdminUser(info);
                    GridViewManager1.GridView.PageIndex = GridViewManager1.GridView.PageCount;
                    GridViewManager1.LoadData();
                }
                catch (Exception ex)
                {
                    Exceptions.Logger.Error(ex);
                    HtmlHelper.Alert(ex.Message, Page);
                }
            }
        }