日期:2014-05-17 浏览次数:20622 次
<asp:TemplateField HeaderText="软件大小">
<ItemTemplate>
<asp:Label ID="lbl_objlen" runat="server" Text='<%# Bind("ObjProgLen") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
#region 转换文件大小
/// <summary>
/// 转换文件大小
/// </summary>
/// <param name="size">文件的大小</param>
/// <returns></returns>
public static string ReturnFileSize(object osize)
{
int site=int.Pause(osize.ToString());
string FileSize = ""; if (size != 0)
{
if (size >= 1073741824)
{
FileSize = System.Math.Round(Convert.ToDouble((double)size / (double)1073741824), 2).ToString() + "GB"; //GB
}
else if (size >= 1048576)
{
FileSize = System.Math.Round(Convert.ToDouble((double)size / (double)1048576), 2).ToString() + "MB";
}
else if (size >= 1024)
{
FileSize = System.Math.Round(Convert.ToDouble((double)size / (double)1024), 2).ToString() + "KB"; int a = size / 1024 * 100; int b = size / 1024;
}
else
{
FileSize = size.ToString() + "bytes";
}
}
else { FileSize = size.ToString() + "bytes"; } return FileSize;
}