可可果

哈利是一只有白点的黑狗

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
后置代码中的计算方法
 
public int FormatVoteCount(string VOTE_NUMBER, string VOTE_REMARK)
    {
        
if (VOTE_NUMBER.Length <= 0 || VOTE_REMARK.Length <= 0)
        {
            
return (0);
        }
        
int nVOTE_REMARK = Int32.Parse(VOTE_REMARK);
        
if (nVOTE_REMARK > 0)
        {
            
return ((Int32.Parse(VOTE_NUMBER) * 100 / nVOTE_REMARK));
        }
        
return (0);
    }

前置代码中的数据绑定

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="100%">
            
<Columns>
                
<asp:TemplateField HeaderText="题号">
                    
<ItemTemplate>
                       
<%#DataBinder.Eval(Container.DataItem,"VOTEID")%>
                    
</ItemTemplate>
                
</asp:TemplateField>
                
<asp:TemplateField HeaderText="百分比">
                    
<ItemTemplate>
                        
<asp:Image ID="Image1" Width='<%#FormatVoteCount(DataBinder.Eval(Container.DataItem,"VOTE_NUMBER").ToString(),"100") %>' runat="server" ImageUrl="~/Images/vote.gif" /><%#FormatVoteCount(DataBinder.Eval(Container.DataItem,"VOTE_NUMBER").ToString(),"100")%>%
                    
</ItemTemplate>
                
</asp:TemplateField>
                
<asp:TemplateField HeaderText="总票数">
                    
<ItemTemplate>
                       
<%#DataBinder.Eval(Container.DataItem,"VOTE_REMARK")%>
                    
</ItemTemplate>
                
</asp:TemplateField>
            
</Columns>
        
</asp:GridView>
posted on 2007-10-17 17:08  可可果  阅读(332)  评论(0编辑  收藏  举报