我在GridView的RowDataBound中计算了一个值,我想把他显示在前台的GridView中。请问应该如何绑定?
求高手!

解决方案 »

  1.   


     <asp:TemplateField>
     <HeaderTemplate>工时</HeaderTemplate>
     <ItemTemplate>
     <asp:Label runat="server" ID="labItemHours"></asp:Label>
     </ItemTemplate>
     </asp:TemplateField>这样如何从RowDataBind中的给他赋值!
      

  2.   

    <%# Eval(方法名("参数字段"))%>
      

  3.   

    那就在 RowDataBound 中给当前行中的 Label 赋值就可以了用 e.Row.FindControl("labItemHours") as   Label 如果位置固定,索引的效率要比 FindControl高
      

  4.   

    e.Row.FindControl("labItemHours") 
      

  5.   

    <asp:Label ID="label1" ruant="Server" text = "<%# GetStr(Eval("name"))%>">public string GetStr(string name)
    {
        return "hello "+name";}