protected void Page_Load(object sender, EventArgs e) { CurrentTable = SiteTable.Tables.Find(a => { return(a.ID == TableID); }); TableName = CurrentTable.TableName; CurrentFields = CurrentTable.Columns; if (!IsPostBack) { if (CurrentFields == null || CurrentFields.Count == 0) { SiteTable.RefreshField(CurrentTable); } BindData(); } }
/// <summary> /// 批量删除 刷新表结构 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDelete_Click(object sender, EventArgs e) { Int32 arguments = Convert.ToInt32(Request.Form["__EVENTARGUMENT"]); switch (arguments) { case 1: SiteTable.RefreshField(CurrentTable); this.BindData(); break; case -1: List <SiteTable> list = new List <SiteTable>(); foreach (RepeaterItem item in Repeater1.Items) { HtmlInputCheckBox chk = item.FindControl("id") as HtmlInputCheckBox; if (chk.Checked) { var field = CurrentFields.Find(a => { return(a.ID == Guid.Parse(chk.Value)); }); if (field.FieldName == "id" || field.FieldName == "settingsxml") { continue; } if (field != null) { if (!field.isVirtual) { String sql = String.Format("ALTER TABLE {0} DROP COLUMN {1}", TableName, field.FieldName); db.ExecuteCommand(sql); } CurrentFields.Remove(field); } } } SiteTable.SaveTables(SiteTable.Tables); this.BindData(); break; } }