Sunday, November 16, 2014

HTML Decode a collection of column names in a Data Table

    /// <summary>
        /// HTML Decode a collection of column names in a Data Table
        /// </summary>
        /// <param name="dTable"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public static DataTable HtmlDecodeDataTable(DataTable dTable, List<string> fieldNames)
        {
            foreach (DataRow drow in dTable.Rows)
            {
                foreach (string fieldName in fieldNames)
                {
                    if (drow[fieldName] != null && drow[fieldName].GetType().IsEquivalentTo(typeof(string)))
                    {
                        drow[fieldName] = System.Web.HttpUtility.HtmlDecode((drow[fieldName].ToString()));
                    }
                }
            }
            dTable.AcceptChanges();
            return dTable;
        }

No comments:

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...