forum

Home / DeveloperSection / Forums / How to set file size in grid view

How to set file size in grid view

Anonymous User 1834 20-Nov-2014

I need help setting the size of flies in a grid-view, this first set of code works

protected string DisplaySize(long? size)
{
    if (size == null)
        return string.Empty;
    else
    {
        if (size <1024)
        {
            return string.Format("{0:#} bytes", size.Value);
        }
        else
        {
            return String.Format("{0:#} KB", size.Value / 1024);
        }
    }

When I try to add more values it dose not work I just get blank values 

protected string DisplaySize(long? size)
{
    if (size == null)
        return string.Empty;
    else
    {
        if (size < 1024)
        {
            return string.Format("{0:#} bytes", size.Value);
        }
        else if(size < 10240)
        {
            return String.Format("{0:#} KB", (size.Value / 1024));
        }
        else if(size < 102400)
        {
            return String.Format("{0:#} MB", (size.Value / 1024 / 1024));
        }
        else
        {
            return String.Format("{0:#} GB", (size.Value / 1024 / 1024 / 1024));
        }
    }
}

Updated on 20-Nov-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By