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("Mask", typeof(string)); dt.Columns.Add("CounterLength", typeof(int)); dt.Columns.Add("CounterReset", typeof(string)); dt.Columns.Add("Scope", typeof(string)); dt.Columns.Add("IsUsed", typeof(bool)); foreach (MetaFieldType mfType in MetaDataWrapper.GetIdentifierList()) { DataRow dr = dt.NewRow(); dr["Name"] = mfType.Name; dr["FriendlyName"] = CHelper.GetResFileString(mfType.FriendlyName); dr["Mask"] = mfType.Attributes[McDataTypeAttribute.IdentifierMask].ToString(); dr["CounterLength"] = int.Parse(mfType.Attributes[McDataTypeAttribute.IdentifierMaskDigitLength].ToString()); dr["CounterReset"] = GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "CounterReset" + mfType.Attributes[McDataTypeAttribute.IdentifierPeriodType].ToString()); dr["Scope"] = GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Scope" + mfType.Attributes[McDataTypeAttribute.IdentifierType].ToString()); dr["IsUsed"] = MetaIdentifier.IsUsed(mfType); dt.Rows.Add(dr); } DataView dv = dt.DefaultView; if (Session["IdentifierList_Sort"] == null) { Session["IdentifierList_Sort"] = "Name"; } dv.Sort = Session["IdentifierList_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("IbnFramework.GlobalMetaInfo", "Delete").ToString() + "?')"); } } }
protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Delete") { MetaFieldType type = MetaDataWrapper.GetIdentifierByName(e.CommandArgument.ToString()); if (!MetaIdentifier.IsUsed(type)) { MetaIdentifier.Remove(type); } BindData(); } if (e.CommandName == "Edit") { Response.Redirect("~/Apps/MetaDataBase/Pages/Admin/IdentifierEdit.aspx?type=" + e.CommandArgument.ToString() + "&back=list"); } }