I'm stuck in a gridview operation. Baiscally i have an sql that select filesize from database. I need to convert the file ti Giga byte. So i cant find a method to do it in sql, what i plan to do is. Get the result from the sql, convert the result to GB using some function then assign the value to the column in the gridview. How can i do this. Can somebody help.

For now this is what I have.

Front End

<asp:GridView   ID="dgSpaceUsage" align="left" AutoGenerateColumns="False" 
                        EnableViewState="False" runat="server" 
                        Width = "598px"  BackColor = "#DFDFDF" BorderColor = "Red" 
                        BorderStyle = "Dotted" ForeColor = "Black" BorderWidth = "2px" 
                        CellPadding = "2"  CellSpacing = "2" DataSourceID="SqlDataSource1" 
                        AlternatingRowStyle-BackColor="#f5f5f5" AllowSorting="True">
               <HeaderStyle BackColor="SeaShell" ForeColor="Black"/>
                <asp:BoundField DataField="domainname" ReadOnly="True" HeaderText="Domain Name" SortExpression="domainname" />
                <asp:BoundField DataField="transferdomainname" ReadOnly="True" HeaderText="Transfer Domain Name" SortExpression="transferdomainname" />
                <asp:BoundField DataField="totalsize" ReadOnly="True" HeaderText="Total Size" SortExpression="totalsize" />
                    <AlternatingRowStyle BackColor="WhiteSmoke" />
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:XimplifyConnectionString %>" 
                        SelectCommand="SELECT top 15 a.domainname,a.transferdomainname, sum(cast(filesize/1024*1024 as bigint))as totalsize FROM tbl_mediafiles m,tbl_useraccounts a where a.accountid=m.createdby GROUP BY a.domainname,a.transferdomainname order by totalsize desc"></asp:SqlDataSource>

The total size i get now is in bytes in the form of 4387672143 instead i need to convert it as 4.4GB.

Can anyone help me. :-/

Thanks in advance


U need to convert your Bound Field to Template field
Try doing this..

<asp:TemplateField HeaderText="Total Size">
                      <asp:Lable ID="Label1" runat="server" Text='<%# Eval("totalsize")/(1024*1024*1024) %>' />