user1500633
user1500633

Reputation:

How to add Comma for total in the gridview footer

Do anyone know how to give comma for the calculated total value displaying in grid view Footer in asp.net c#?

Eg:12,492,323

Upvotes: 0

Views: 1032

Answers (2)

Tianzhen Lin
Tianzhen Lin

Reputation: 2624

Without code posted, it is hard to answer your question precisely.

Assuming in your code behind you calculate the total, instead of putting in the total as total.ToString(), use total.ToString("N0") instead.

Upvotes: 2

Chamika Sandamal
Chamika Sandamal

Reputation: 24302

protected void grdList_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.Footer)
    {
        Label lbl = (Label)(e.Row.FindControl("lblTotal"));
        lbl.Text = String.Format("{0:n}", Total);
    }
}

Upvotes: 2

Related Questions