/// <summary> /// Binds the data. /// </summary> private void BindData() { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("Name", typeof(string))); dt.Columns.Add(new DataColumn("FriendlyName", typeof(string))); if (TypeName != string.Empty) { MetaFieldType mft = MetaDataWrapper.GetTypeByName(TypeName); if (mft != null) { txtMRTName.Text = mft.Name; txtMRTName.ReadOnly = true; txtMRTName.CssClass = "text-readonly"; txtFriendlyName.Text = mft.FriendlyName; } DataRow dr; foreach (MultiReferenceItem mri in MultiReferenceType.GetMultiReferenceItems(mft)) { dr = dt.NewRow(); dr["Name"] = mri.MetaClassName; dr["FriendlyName"] = mri.MetaClassName; dt.Rows.Add(dr); } dgClasses.Columns[2].Visible = false; } ViewState["DT_Source"] = dt; BindDG(); }
/// <summary> /// Handles the ServerClick event of the imbtnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void imbtnSave_ServerClick(object sender, EventArgs e) { Page.Validate(); if (!Page.IsValid) { return; } if (TypeName == string.Empty) { string typeName = String.Empty; using (MetaClassManagerEditScope editScope = DataContext.Current.MetaModel.BeginEdit()) { DataTable dt = (DataTable)ViewState["DT_Source"]; List <MultiReferenceItem> mas = new List <MultiReferenceItem>(); foreach (DataRow dr in dt.Rows) { mas.Add(new MultiReferenceItem(dr["Name"].ToString(), dr["Name"].ToString(), dr["FriendlyName"].ToString())); } MetaFieldType type = MultiReferenceType.Create(txtMRTName.Text, txtFriendlyName.Text, mas.ToArray()); typeName = type.Name; editScope.SaveChanges(); } //if (typeName != String.Empty) // Response.Redirect(String.Format("~/Apps/MetaDataBase/Pages/Admin/MultiReferenceTypeView.aspx?type={0}", typeName)); //else Response.Redirect("~/Apps/MetaDataBase/Pages/Admin/MultiReferenceTypeList.aspx"); } else { MetaFieldType type = MetaDataWrapper.GetTypeByName(TypeName); type.FriendlyName = txtFriendlyName.Text; Response.Redirect(String.Format("~/Apps/MetaDataBase/Pages/Admin/MultiReferenceTypeView.aspx?type={0}", TypeName)); } }
private void LoadRequestVariables() { if (Request.QueryString["type"] != null) { TypeName = Request.QueryString["type"]; mft = MetaDataWrapper.GetTypeByName(TypeName); } }
/// <summary> /// Handles the RowCommand event of the grdMain control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewCommandEventArgs"/> instance containing the event data.</param> protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Delete") { MetaFieldType type = MetaDataWrapper.GetTypeByName(e.CommandArgument.ToString()); if (!MetaFieldType.IsUsed(type)) { MultiReferenceType.Remove(type); } BindData(); } if (e.CommandName == "Edit") { MetaFieldType type = MetaDataWrapper.GetTypeByName(e.CommandArgument.ToString()); Response.Redirect("~/Apps/MetaDataBase/Pages/Admin/MultiReferenceTypeEdit.aspx?type=" + type.Name); } }