Exemple #1
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("Type", typeof(string));
            dt.Columns.Add("IsUsed", typeof(bool));

            foreach (MetaFieldType mfType in MetaDataWrapper.GetEnumList())
            {
                DataRow row = dt.NewRow();
                row["Name"]         = mfType.Name;
                row["FriendlyName"] = CHelper.GetResFileString(mfType.FriendlyName);
                if (mfType.Attributes.ContainsKey(McDataTypeAttribute.EnumMultivalue))
                {
                    row["Type"] = GetGlobalResourceObject("GlobalMetaInfo", "MultiValue").ToString();
                }
                else
                {
                    row["Type"] = GetGlobalResourceObject("GlobalMetaInfo", "SingleValue").ToString();
                }
                row["IsUsed"] = MetaEnum.IsUsed(mfType);
                dt.Rows.Add(row);
            }
            DataView dv = dt.DefaultView;

            if (this.Session["EnumList_Sort"] == null)
            {
                this.Session["EnumList_Sort"] = "FriendlyName";
            }
            dv.Sort = this.Session["EnumList_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() + "?')");
                }
            }
        }