Ejemplo n.º 1
0
 /// <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);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            DataTable dt = new DataTable();

            dt.Locale = CultureInfo.InvariantCulture;
            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("FriendlyName", typeof(string));
            dt.Columns.Add("IsUsed", typeof(bool));

            foreach (MetaFieldType mfType in DataContext.Current.MetaModel.GetRegisteredTypes(McDataType.MultiReference))
            {
                DataRow row = dt.NewRow();
                row["Name"]         = mfType.Name;
                row["FriendlyName"] = CHelper.GetResFileString(mfType.FriendlyName);
                row["IsUsed"]       = MetaFieldType.IsUsed(mfType);
                dt.Rows.Add(row);
            }
            DataView dv = dt.DefaultView;

            if (this.Session["MRTList_Sort"] == null)
            {
                this.Session["MRTList_Sort"] = "FriendlyName";
            }
            dv.Sort = this.Session["MRTList_Sort"].ToString();

            grdMain.DataSource = dv;
            grdMain.DataBind();

            foreach (GridViewRow row in grdMain.Rows)
            {
                ImageButton ib = (ImageButton)row.FindControl("ibDelete");

                if (ib != null)
                {
                    ib.Attributes.Add("onclick", "return confirm('" + GetGlobalResourceObject("GlobalMetaInfo", "Delete").ToString() + "?')");
                }
            }
        }