开发者

Int values get automatically converted into float values on Binding the text values in gridview

开发者 https://www.devze.com 2023-01-05 07:42 出处:网络
I am开发者_StackOverflow社区 getting int values from the stored procedure. But when i bind this datasource with the gridview i am seeing the values being converted into float.

I am开发者_StackOverflow社区 getting int values from the stored procedure. But when i bind this datasource with the gridview i am seeing the values being converted into float. i am using Text='<% # Bind("Quantity") %'

I wanna that to be displayed as int, with out zero's eg: let the value be 233, when i bind that its getting displayed as 233.00


try this:

Text='<%# Bind("Quantity", "{0:0}") %>'

This link has a pretty complete list and explanation of the string formatting codes. They can be goofy sometimes, say with the double.ToString(formatCode) method:

var a = 12344.00;
Console.WriteLine(a.ToString("0"));

Outputs the same as this in binding syntax

Eval(12344.00, "{0:0}")
0

精彩评论

暂无评论...
验证码 换一张
取 消