I need to set the width of the LabelProgressBar2 to the value of num
(default if the html is "Width="50.9999%"). It used the value of
"score" (a 0 to 1 fraction) *100. This is all very new as I am juat
getting stated so any and all constructive critisim is welcomed (of
course a fix for the problem wouls be great too)  :).

[code]
<asp:GridView ID="GridView1" runat="server"
OnRowDataBound="GridView1_RowDataBound">
       <columns>
        <asp:templatefield headertext="Percent Score">
          <itemtemplate>

          <asp:Label ID="ProgressBarContainer2" runat="server"
            Height="22px" Width="220px" BackColor="Red"
            Style="border-color: white; border-width: 3px; border-
style: ridge;">
            <asp:Label ID="LabelProgressBar2" runat="server"
                Style="padding-left: 2px; font-weight:bold;"
                Width="50.9999%"
                Text='<%# Bind("score", "{0:00.0000%}") %>'
                Height="100%"
                BackColor="Green">
            </asp:Label>
          </asp:Label>

          </itemtemplate>
         </asp:templatefield>
        </columns>
    </asp:GridView>
[/code]

The code behind snipit...
[code]
    protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)// Make sure
it's a datarow
        {
            DataRow pr = ((DataRowView)e.Row.DataItem).Row;
            double num = Convert.ToDouble(pr["score"]);
            num *= 100;
            if (num <= 99.9)// Establish threshold
                e.Row.Cells[4].ForeColor = System.Drawing.Color.Red;//
Set text color to RED if less than threshold

//Need to replace the value of the label width with num. The below is
NOT working :(
            Label barwidth = (label)e.Row.FindControl
("LabelProgressBar2");
            barwidth.Width = num;

        }
    }
[/code]

Reply via email to