Welcome Guest Search | Active Topics | Sign In | Register

EO.ProgressBar inside GridView Column Options
d347hm4n
Posted: Monday, April 27, 2009 6:50:18 AM
Rank: Newbie
Groups: Member

Joined: 4/27/2009
Posts: 6
Hello all,

I'm making a gridview in an asp.net 3.5 webpage.

I have an Int32 Column which will contain a value between 0 - 100.

I would like to represent this value with the eo.ProgressBar.

How do I achieve this.

I have installed the demo, but I would like to do this from the code behind.

Thanks!
eo_support
Posted: Monday, April 27, 2009 7:41:12 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
You don't need a ProgressBar for that at all. Use a DIV with a background color and then set the width of the DIV based on your data field value is enough for that.

Thanks!
d347hm4n
Posted: Monday, April 27, 2009 7:50:33 AM
Rank: Newbie
Groups: Member

Joined: 4/27/2009
Posts: 6
Thanks for the reply.

I hadn't thought of using a DIV!

I will try and do it that way.

I was rather hoping of using the progress bar because it looks very sexy!

So there is no way of using the progress bar to represent the value?




eo_support
Posted: Monday, April 27, 2009 8:10:24 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
There is. The ProgressBar is a standard server control. So you would simply put it inside a TemplateField and data bind to its Value property as you would with any other property of any standard ASP.NET control. However by using a progress bar you are using a cannon to shoot a fly here. The core feature of the ProgressBar is for you to dynamically update progress, it's not for you to display static information. For displaying static information you should always look for a static solution such as div or images.
d347hm4n
Posted: Monday, April 27, 2009 8:19:51 AM
Rank: Newbie
Groups: Member

Joined: 4/27/2009
Posts: 6
I appreciate that I am blowing a fly apart with a cannon.

But I blow it apart in a sexy way!

I will be updating the page every 30seconds so I doesn't need to be inside an update panel.

I'm using the control to display the number of free machines on a floor in a library, so it is perfect for me. Thanks!
d347hm4n
Posted: Tuesday, April 28, 2009 8:40:12 AM
Rank: Newbie
Groups: Member

Joined: 4/27/2009
Posts: 6
I will post my results so that anyone else will be able to do it.

Markup for gridView:
Code:

<asp:GridView ID="gvFloors" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" onrowdatabound="gvFloors_RowDataBound">
            <Columns>
                <asp:BoundField DataField="Site" HeaderText="Site" SortExpression="Site" />
                <asp:BoundField DataField="Floor" HeaderText="Floor" SortExpression="Floor" />
                <asp:BoundField DataField="Machines" HeaderText="Machines" ReadOnly="True" SortExpression="Machines" />
                <asp:TemplateField HeaderText="Overview">
                    <ItemTemplate>
                        <eo:ProgressBar ID="ProgressBar1" runat="server" Width="250px" Visible="true" ControlSkinID="Windows_Vista" ShowPercentage="true">
                        </eo:ProgressBar>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <HeaderStyle CssClass="GridHeader" />
            <RowStyle CssClass="GridRow" />
            <AlternatingRowStyle CssClass="GridAltRow" />
        </asp:GridView>



Code Behind:

Code:

    protected void gvFloors_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string[] txtSplit = e.Row.Cells[2].Text.Split('/');
            ProgressBar bar = (ProgressBar)e.Row.FindControl("ProgressBar1");
            bar.Value = ConvertToPercentage(Int32.Parse(txtSplit[1].ToString()),Int32.Parse(txtSplit[0].ToString()));
        }
    }

    private int ConvertToPercentage(int numerator, int denominator)
    {
        return ((numerator / denominator) * 100);
    }


Thank you essential objects, your controls are BRILLIANT!
eo_support
Posted: Tuesday, April 28, 2009 8:42:52 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Thanks for sharing! Glad that you like our product!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.