Description:-
In this example we explain that how to display
currency symbol in gridview column in asp.net
or set currency symbol for salary column of the gridview in asp.net.
This was real problem that I was faced that in my project we have a one column salary in employee table. And requirement is that if employee's city is UK then we have to set currency symbol ahead of salary is "$" if employee's city is India then display simple salary as in database and also same for other multiple employee country.
So this is very important thing and very useful feature that we have require in many project. So to achieve this type of functionality follow the below steps
This was real problem that I was faced that in my project we have a one column salary in employee table. And requirement is that if employee's city is UK then we have to set currency symbol ahead of salary is "$" if employee's city is India then display simple salary as in database and also same for other multiple employee country.
So this is very important thing and very useful feature that we have require in many project. So to achieve this type of functionality follow the below steps
To show Example of How to Upload Multiple File in MVC Application then click here upload multiple File in MVC
How to upload File and Fetch file from SqlServer and bind to Gridview fetch file from Sqlserver and bind to Gridview
<%@
Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Display
Currency Symbol in Gridview in asp.Net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White"
BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" CellPadding="4">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:BoundField DataField="NAME" HeaderText="NAME" />
<asp:BoundField DataField="country" HeaderText="Country" />
<asp:BoundField DataField="SALARY" HeaderText="SALARY" DataFormatString="{0:c}" />
</Columns>
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
<PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
<RowStyle BackColor="White" ForeColor="#330099" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
<SortedAscendingCellStyle BackColor="#FEFCEB" />
<SortedAscendingHeaderStyle BackColor="#AF0101" />
<SortedDescendingCellStyle BackColor="#F6F0C0" />
<SortedDescendingHeaderStyle BackColor="#7E0000" />
</asp:GridView>
</div>
</form>
</body>
</html>
Default2.aspx.cs:-
using System;
using
System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using
System.Web.UI.WebControls;
using System.Data;
using
System.Data.SqlClient;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object
sender, EventArgs e)
{
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
data();
}
public void data()
{
DataTable
dt = new DataTable();
dt.Columns.Add("Name");
dt.Columns.Add("country");
dt.Columns.Add("Salary");
DataRow
dr = dt.NewRow();
dr[0] = "kirit";
dr[1] = "India";
dt.Rows.Add(dr);
DataRow
dr1 = dt.NewRow();
dr[2] = "15000";
dr1[0] = "pintu";
dr1[1] = "India";
dr1[2] = "35000";
dt.Rows.Add(dr1);
GridView1.DataSource = dt;
GridView1.DataBind();
con.Close();
}
}
0 comments:
Post a Comment