Forums » .NET » ASP.NET »

Display negative values in gridview


Posted Date: 27 Oct 2011      Posted By:: vineet     Member Level: Gold    Member Rank: 272     Points: 2   Responses: 2



Hi all,

I have a gridview which dispalys the negative numbers in a column like ($2.00). It automatically applies brackets where it gets negative value.

How to restrict it and my coulumn should show negative like -$2.00.

Please help

thanks
Vineet




Responses

#639307    Author: sharad      Member Level: Bronze      Member Rank: 5337     Date: 28/Oct/2011   Rating: 2 out of 52 out of 5     Points: 2

String.Format("{0:$#,##0.00;($#,##0.00);Zero}", value);

This will output "$1,240.00? if passed 1243.50. It will output the
same format but in parentheses if the number is negative, and will
output the string "Zero" if the number is zero.


 
#639309    Author: sharad      Member Level: Bronze      Member Rank: 5337     Date: 28/Oct/2011   Rating: 2 out of 52 out of 5     Points: 3

Uae a TemplateField instead:

http://msdn.microsoft.com/en-us/library/bb288032.aspx[^]

Your code woould then be something like:


Collapse | Copy Code

<asp:TemplateField HeaderText="Price">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='$<%#
Bind("Price") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>


 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : Percentage progressbar in asp.net
Previous : How to change selected row color in datagrid using asp.net
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages

Subscribe to Subscribers
Awards & Gifts
Talk to Webmaster Tony John
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India