我想设置某一列下面的脚模版  
前台
<asp:TemplateField HeaderText="投资收益(元)">
                               
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("money") %>'></asp:Label>
                                </ItemTemplate>
                                <FooterTemplate>
                                    <asp:Label ID="lbltotal" runat="server" Text=""></asp:Label>
                                </FooterTemplate>
                            </asp:TemplateField>
后台
 if (e.Row.RowType == DataControlRowType.Footer)
        {
            ((Label)e.Row.FindControl("lbltotal")).Text ="总计:"+ it.ToString();
        }但是这样 脚模版 怎么显示不出来  有谁知道怎么样显示吗?

解决方案 »

  1.   


    ShowFooter="True"
      
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        if (e.Row.RowType == DataControlRowType.DataRow)     
         {
           sum+= Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Price"));       
         }            
        else if(e.Row.RowType == DataControlRowType.Footer)                              {                     e.Row.Cells[3].Text="合计:";                   
        e.Row.Cells[4].Text =sum.ToString();          
    }    
    if (e.Row.RowType == DataControlRowType.DataRow) {           
      sum+= Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Price"));  
     }       else if(e.Row.RowType == DataControlRowType.Footer)         {                e.Row.Cells[3].Text="合计:";               e.Row.Cells[4].Text =sum.ToString();     }  
      

  2.   

    ShowFooter默认是false
    你改成true
      

  3.   

    2楼的解决方案是可以解决问题的,你需要在检查自己的代码。1)楼主的it.ToString(); it必须定为全局变量.2)试这种方式找控件。 Label total= Gridview1.FooterRow.FindControl("lbltotal") as Label ;