ASP.NET - Display Monet Type Data in Grideview Itemtemplate textbox control

Asked By Naresh Kumar on 22-Nov-10 06:25 AM
Hi,

I have to dipaly 2 digits after the decimal point .In DB The keyword is money
How can i handle it in Asp.net gridview Itemtemplatefield + TextBox control

My Code:

<ItemTemplate>

<asp:TextBox ID="txtP2" MaxLength="10"  AutoPostBack="true"

OnTextChanged="txtChange" Width="50px" Text='<%# Eval("P2")%>' runat="server">

</ItemTemplate>

Plz help

Plz help

Danasegarane Arunachalam replied to Naresh Kumar on 22-Nov-10 06:38 AM
Handle the formating option

<%# DataBinder.Eval(Container.DataItem, "Price", "{0:c}") %>


The above will display the price in currency

Refer:http://msdn.microsoft.com/en-us/library/2d76z3ck.aspx
Naresh Kumar replied to Danasegarane Arunachalam on 22-Nov-10 07:03 AM
it is not working
Danasegarane Arunachalam replied to Naresh Kumar on 22-Nov-10 07:09 AM
Post the code
Naresh Kumar replied to Danasegarane Arunachalam on 22-Nov-10 07:16 AM

<asp:TextBox ID="txtP1" MaxLength="10" onkeypress="return numeralsOnly(event)" AutoPostBack="true"

OnTextChanged="txtChange" Width="50px" Text='<%#DataBinder.Eval(Container.Dataitem,"P1","{0:c}")%>' runat="server"></asp:TextBox>

Danasegarane Arunachalam replied to Naresh Kumar on 22-Nov-10 07:20 AM
Did you debug the code. What is the value for P1 and what it displaing