1

I am trying to get the comma separated values .. here is my UI code

 <table id="dtreport" class="table table-striped table-bordered table-response">
            <thead>
                <tr>
                    @foreach (System.Data.DataColumn col in Model.Columns)
                    {
                        if (col.ColumnName != "PackageDataID")
                        {
                        <th>@col.ColumnName</th>
                    }
                }
                </tr>
            </thead>
            <tbody>
                @foreach (System.Data.DataRow row in Model.Rows)
                {
                    <tr>
                        @foreach (System.Data.DataColumn col in Model.Columns)
                        {
                            if (col.ColumnName != "PackageDataID")
                            {
                                if (col.ColumnName == "IPC" || col.ColumnName == "From Date" || col.ColumnName == "To Date")
                                {
                            <td style="text-align: center">@row[col.ColumnName]</td>
                            }
                            else
                            {
                            <td style="text-align: right">@System.Globalization.CultureInfo.CurrentCulture.@row[col.ColumnName]</td>
                            }
                        }
                    }
                    </tr>
            }
            </tbody>
        </table>

i am trying to set the globalization in body, as i have seen this format in google search.... i set my globalization in web.config as

 <globalization uiCulture="hi" culture="hi-IN" />

but the output was not as expected.. please have a look into the image.. output when i add the globalization.currentculture in body of table

tereško
  • 58,060
  • 25
  • 98
  • 150
thiru
  • 173
  • 1
  • 4
  • 16

1 Answers1

0

you can define simple Extension Method to do this for you. then call it in razor. only you need to use namesapace of extension method

 public static string separate(this string value)
    {
        // you need additional code to find digit value to separate them. then pass it to regex method.
        return System.Text.RegularExpressions.Regex.Replace(value, ".{3}", "$0,");
    }

in razor

@row[col.ColumnName].tostring().separate()

*also you can use javascript and jquery link

Community
  • 1
  • 1
Rev
  • 2,269
  • 8
  • 45
  • 75