Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6799721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:52:56+00:00 2026-05-26T18:52:56+00:00

I am using C# asp.net 4.0 in my project where i need to display

  • 0

I am using C# asp.net 4.0 in my project where i need to display price in India curreny format.

eg. my number is 12550000.00 then i want to display it as 1,25,50,000.00

But i want this to be displayed in gridview when i bind the data to the gridview,

so it can be done in markup page. where we place Eval for each Item Data Bound.

However, i would also like to explain my senario for displaying comma sepearted values.

i have a set of textboxes above the gridview where user makes entries of values and click add.

this gets add in the viewstate and the viewstate is binded to gridview.

In gridview i also have Edit button on click of it the values in viewstate is passed back to textbox on RowCommand Event of gridview. and on update click the viewstate datatable is updated and Binded back to gridview.

FOR your reference:

protected void gvPropertyConfig_RowCommand(object sender, GridViewCommandEventArgs e)
{
    try
    {
        if (e.CommandName == "EditItem")
        {
            int index = Convert.ToInt32(e.CommandArgument);
            hdnIndex.Value = index.ToString();
            DataTable dt = (DataTable)ViewState["proeprtyConfig"];
            DataRow dr = dt.Rows[index];

            if (Request.QueryString["CMD"] == "Edit")
            {
                hdnPropertyConfigID.Value = dr["config_id"].ToString();
                if (dr["is_active"].ToString().ToLower() == "true")
                {
                    chkConfigVisible.Checked = true;
                }
                else
                {
                    chkConfigVisible.Checked = false;
                }
                thIsActHed.Visible = true;
                tdIsActchk.Visible = true;
                tdbtnConfig.ColSpan = 2;
            }

            txtScalableArea.Text = dr["scalable_area"].ToString();
            txtCarpetArea.Text = dr["carpet_area"].ToString();
            txtPricePerSqFt.Text = dr["price_per_sq_ft"].ToString();
            txtCCPricePerSqFt.Text = dr["cc_price_per_sq_ft"].ToString();
            txtTotalPrice.Text = dr["total_price"].ToString();
            ddlNoOfBedrooms.SelectedValue = dr["room_id"].ToString();

            btnUpdateConfig.Visible = true;
            btnConfigSubmit.Visible = false;

        }
        if (e.CommandName == "DeleteItem")
        {
            int index = Convert.ToInt32(e.CommandArgument);
            DataTable dt = (DataTable)ViewState["proeprtyConfig"];
            DataRow dr = dt.Rows[index];
            if (Request.QueryString["CMD"].ToString() == "Edit")
            {
                int PropertyConfigID = Convert.ToInt32(dr[0].ToString());
                prConfigObj.deletePropertyConfig(PropertyConfigID);
                fillData();

            }
            else
            {
                dr.Delete();
                gvPropertyConfig.DataSource = (DataTable)ViewState["proeprtyConfig"];
                gvPropertyConfig.DataBind();
            }
            clearConfigTextBoxes();
            btnConfigSubmit.Visible = true;
            btnUpdateConfig.Visible = false;


        }
        setChecklistAttr();
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

Below is the markup for Gridview,

 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div class="tabBord">
                <table>
                    <tr>
                        <td colspan="4" class="middle">
                            <h4>
                                Property Config Information</h4>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4">
                            <p>
                                Note: Enter total prices in lacs only. Eg. If 1 Crore than enter 1,00,00,000
                            </p>
                            <p>
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div id="divconfigstr" runat="server">
                                Configuration<span style="color: Red">*</span></div>
                            <%--class="displaynon"--%>
                        </td>
                        <td>
                            <div id="divnoofbedrooms" runat="server">
                                <asp:DropDownList Enabled="false" ID="ddlNoOfBedrooms" runat="server">
                                </asp:DropDownList>
                                <p>
                                </p>
                            </div>
                        </td>
                        <td>
                            Scalable Area <span style="color: Red">*</span>
                        </td>
                        <td>
                            <asp:TextBox ID="txtScalableArea" runat="server" autocomplete="off" MaxLength="10"></asp:TextBox><p>
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Carpet Area <span style="color: Red">*</span>
                        </td>
                        <td>
                            <asp:TextBox ID="txtCarpetArea" runat="server" autocomplete="off" MaxLength="10"></asp:TextBox><p>
                            </p>
                        </td>
                        <td>
                            Price/Sq.Ft.<span style="color: Red">*</span>
                        </td>
                        <td>
                            <asp:TextBox ID="txtPricePerSqFt" runat="server" autocomplete="off" MaxLength="10"></asp:TextBox><p>
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            CC Price/Sq.Ft.<span style="color: Red">*</span>
                        </td>
                        <td>
                            <asp:TextBox ID="txtCCPricePerSqFt" runat="server" autocomplete="off" MaxLength="10"></asp:TextBox><p>
                            </p>
                        </td>
                        <td>
                            Total Price (in lacs)<span style="color: Red">*</span>
                        </td>
                        <td>
                            <asp:TextBox ID="txtTotalPrice" runat="server" autocomplete="off" MaxLength="10"></asp:TextBox><p>
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <td id="thIsActHed" runat="server">
                            Active
                            <asp:HiddenField ID="hdnPropertyConfigID" runat="server" />
                            <asp:HiddenField ID="hdnIndex" runat="server" />
                        </td>
                        <td id="tdIsActchk" runat="server">
                            <asp:CheckBox ID="chkConfigVisible" runat="server" CssClass="checklist" /><p>
                            </p>
                        </td>
                        <td id="tdbtnConfig" runat="server" colspan="2">
                            <div class="btnHold">
                                <asp:Button ID="btnConfigSubmit" runat="server" Text="Add" OnClientClick="return ValidatePropertyConfig();"
                                    CssClass="sendBtn" OnClick="btnConfigSubmit_Click" />
                                &nbsp;
                                <asp:Button ID="btnUpdateConfig" runat="server" OnClick="btnUpdateConfig_Click" OnClientClick="return ValidatePropertyConfig();"
                                    CssClass="sendBtn" Text="Update" Visible="False" />
                                <asp:Label ID="lblerrconfig" CssClass="errormsg" runat="server"></asp:Label>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4">
                            <div class="pHold">
                                <div class="gridH">
                                    <asp:GridView ID="gvPropertyConfig" runat="server" AutoGenerateColumns="False" OnRowCommand="gvPropertyConfig_RowCommand"
                                        OnRowDataBound="gvPropertyConfig_RowDataBound">
                                        <Columns>
                                            <asp:TemplateField HeaderText="No Of Bedrooms" ItemStyle-CssClass="txtLT">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblno_of_bedrooms" runat="server" Text='<%# Eval("room_no") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Scalable Area" ItemStyle-CssClass="txtRT">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="txtscalable_area" runat="server" Text='<%# Eval("scalable_area") %>'></asp:TextBox>
                                                </EditItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="lblscalable_area" runat="server" Text='<%# Eval("scalable_area") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Carpet Area" ItemStyle-CssClass="txtRT">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="txtcarpet_area" runat="server" Text='<%# Eval("carpet_area") %>'></asp:TextBox>
                                                </EditItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="lblcarpet_area" runat="server" Text='<%# Eval("carpet_area") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Price/SqFt." ItemStyle-CssClass="txtRT">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="txtprice_per_sq_ft" runat="server" Text='<%# Eval("price_per_sq_ft") %>'></asp:TextBox>
                                                </EditItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="lblprice_per_sq_ft" runat="server" Text='<%# Eval("price_per_sq_ft") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="CC Price/SqFt." ItemStyle-CssClass="txtRT">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="txtcc_price_per_sq_ft" runat="server" Text='<%# Eval("cc_price_per_sq_ft") %>'></asp:TextBox>
                                                </EditItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="lblcc_price_per_sq_ft" runat="server" Text='<%# Eval("cc_price_per_sq_ft") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Total Price (in lacs)" ItemStyle-CssClass="txtRT">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="txttotal_price" runat="server" Text='<%# Eval("total_price") %>'></asp:TextBox>
                                                </EditItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="lbltotal_price" runat="server" Text='<%# Eval("total_price") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="" ItemStyle-CssClass="txtLT">
                                                <ItemTemplate>
                                                    <asp:ImageButton runat="server" ID="btnEditItem" CssClass="edBtn" ImageUrl="~/Admin/Includes/Images/edit.png"
                                                        ToolTip="Edit Item" CommandName="EditItem" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" />
                                                    <asp:ImageButton runat="server" ID="btnDeletetem" CssClass="edBtn" ImageUrl="~/Admin/Includes/Images/delete.png"
                                                        CommandName="DeleteItem" ToolTip="Delete Item" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" />
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                        </Columns>
                                    </asp:GridView>
                                </div>
                            </div>
                        </td>
                    </tr>
                </table>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:52:56+00:00Added an answer on May 26, 2026 at 6:52 pm

    Use the “C” parameter in the ToString function, and make sure you set the globalaztion attributes.

    string parseValueIntoCurrency(double number) {
       // set currency format
       string curCulture = Thread.CurrentThread.CurrentCulture.ToString();
       System.Globalization.NumberFormatInfo currencyFormat = new 
           System.Globalization.CultureInfo(curCulture).NumberFormat;
    
       currencyFormat.CurrencyNegativePattern = 1;
    
       return number.ToString("c", currencyFormat);
    }
    

    If you want to use a different Culture (say you’re in USA, and you want the Indian format) then just use the appropriate CultureInfo element rather than getting it out of the current thread.

    EXTRA INFO DUE TO OP EDIT

    All right, what you’re wanting to do to get this into your grid, is to create a PROTECTED function which takes in the number to be converted, and returns the converted string (this is basically the code above.

    Now, on the ASPX side, you need to use that function in your grid view.
    So, instead of this:

     <asp:TemplateField HeaderText="Total Price (in lacs)" >
       <EditItemTemplate>
          <asp:TextBox ID="txttotal_price" runat="server" 
                       Text='<%# Eval("total_price") %>' />
        </EditItemTemplate>
        <ItemTemplate>
           <asp:Label ID="lbltotal_price" runat="server" 
                      Text='<%# Eval("total_price") %>'> />
        </ItemTemplate>
     </asp:TemplateField>
    

    you’ll use this templatefield:

      <asp:TemplateField HeaderText="Total Price (in lacs)" >
        <EditItemTemplate>
           <asp:TextBox ID="txttotal_price" runat="server" 
                        Text='<%# Eval("total_price") %>' />
        </EditItemTemplate>
        <ItemTemplate>
            <%# parseValueIntoCurrency(Eval("total_price")) %>'>
         </ItemTemplate>
     </asp:TemplateField>
    

    Note, two things. The first is that I’m still passing the UNFORMATTED value into the EDIT TEMPLATE, and that I’m not instantiating an extra LABEL in the ITEM TEMPLATE.

    The reason I’m not doing the extra label, is because we just don’t need it in there. That’s just a bit more processor/memory overhead that you just don’t need to incur.

    As for passing the unformatted value to the text field, that’s because it’ll ultimately be easier to validate without having to parse out the commas and other string elements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using SqlCacheDependency with polling in an ASP.NET project. Sometimes, I need to
I'm using MySql in my asp.net project. But I don't want to type every
I'm using asp.NET MVC 2 for my current project and I need to validate
I am using jQuery with ASP.NET in a project. Instead of using ASP.NET Ajax,
I have an ASP.Net project using AJAX that I am putting on a server
I am currently using ASP.NET MVC1 in my project but now i am planing
I am using ASP.NET and C# in my project. I have a requirement where
I am using Asp.Net/C# in my project , in one of my pages I
I am using Asp.Net/C# in my project.I am using Forms Authentication .Currently I call
We are working on a ASP.NET project and we are using the resx files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.