如:
<asp:GridView ID="DataTable" runat="server">
     <Columns> 
        <asp:TemplateField HeaderText="序号"> 
           <ItemTemplate> <%#Container.DataItemIndex + 1 %></ItemTemplate> 
        </asp:TemplateField> 
     </Columns>
</asp:GridView>这样取不到值?
Dim T_Label As Label = CType(DataTable.Rows(1).Cells(0).FindControl(0), Label)
If Not T_Label Is Nothing Then
   Response.Write(T_Label.Text)'取不到值,怎么回事
Else
   Response.Write(DataTable.Rows(1).Cells(0).Controls.Count)'值为1
End If模版列控件的类型是啥呀,郁闷了!
不是Label吗?

解决方案 »

  1.   

    可以把<%#Container.DataItemIndex + 1 %>这一列绑定在label的text属性上你就可以findcontrol("label")了
      

  2.   

    Dim T_Label As Literal= CType(DataTable.Rows(1).FindControl(0), Literal)
      

  3.   

    <ItemTemplate> <%#Container.DataItemIndex + 1 %></ItemTemplate>  
    现在这个没有这样呗<ItemTemplate><asp:Label ID="lb" runat="server" Text=' <%#Container.DataItemIndex + 1 %>'></asp:Label></ItemTemplate> 
      

  4.   

    本帖最后由 net_lover 于 2011-08-09 11:25:36 编辑
      

  5.   


    Dim T_Label As System.Web.UI.DataBoundLiteralControl= CType(DataTable.Rows(1).Cells(0).Controls(0), System.Web.UI.DataBoundLiteralControl)