Comma Separator for Crore and Lac in GridView Column (Indian Format)

In order to show a number with comma separator (Indian Format) for Crore and Lac  in ASP.NET GridView you have to create a function in cs file.....

public string ConvertToIndianFormat(string text)
    {
        if (text != "")
        {
            decimal num = decimal.Parse(text);

            return num.ToString("N", new CultureInfo("hi-IN"));    
        }
        else
        {
            return null;
        }
    }

In aspx...

<asp:TemplateField HeaderText="Amount" >                      
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# ConvertToIndianFormat(Eval("Amount").ToString()) %>' >
                           </asp:Label>
                         </ItemTemplate>
</asp:TemplateField>

Comments

Popular posts from this blog

Crystal Report Font Size Problem

Crystal Report ToWords() Function For Crore and Lac

Generate Auto ID With Prefix