哎,作为一个菜鸟我很郁闷
我做百分比条
但是我数据库取出来的数据是百分比  例如50%
但是我直接赋值不让写在宽度 上
 我请问下有什么办法么
 图片是1px的有的人说Eval可以写 但是Eval 怎么获取页面的CS设定的属性?
大侠救命啊

解决方案 »

  1.   

    控制图片的长短,表现百分比条是最简单的方式。
    <img height="10px" src="bar.gif" width='<%#WidthImg(Eval("Bouns").ToString())%>'/>  
      public float WidthImg(string exp)
        {
            float width;
            string Temp = Int32.Parse(exp) == 0 ? "1" : exp;
            width = Int32.Parse(exp) * 300 / Int32.Parse(Temp);
            return width;
        }以上是按数值生成,百分比的思路类似。
      

  2.   

     string strWidth = "50%"; this.Image1.Width = (Unit)decimal.Parse(strWidth.TrimEnd('%'));
      

  3.   

    <asp:Image ID="voteImage" Runat="server" Height="20" Width='<%#
    FormatVoteImage(FormatVoteCount(DataBinder.Eval(
    Container.DataItem,"VoteCount").ToString()))%>'  
    mageUrl="Images/vote.gif">
    </asp:Image>
    public int FormatVoteCount(String voteCount)
    {  
     if(voteCount.Length <= 0)
     {  
      return(0);
     }
     if(voteTotal > 0)
     {  
      return((Int32.Parse(voteCount)* 100/voteTotal));
     }
     return(0);
    }
    public int FormatVoteImage(int voteCount)
    {
     return(voteCount * 3);
    }