请问下,我在DataGrid里模版列
<ItemTemplate>
<asp:Table id="Table1" runat="server" Width="520px" GridLines="Both" HorizontalAlign="Center"></asp:Table>
</ItemTemplate>我在DataGrid的 ItemDataBound  事件中处理Table
TableRow tRow = new TableRow();
Table2.Rows.Add(tRow);
TableCell tCell = new TableCell();
tCell.Text="ghghh";
tRow.Cells.Add(tCell); 
它说找不到Table2的类空间,我该怎么办?
高手给代码

解决方案 »

  1.   

    没有定义Table2吧可能要实例化 学习
      

  2.   

    我不知到在后台怎么定义啊。
    在后台new Table是肯定不行的啊
      

  3.   

    <ItemTemplate>
    <asp:Table id="Table1" runat="server" Width="520px" GridLines="Both" HorizontalAlign="Center"></asp:Table>
    </ItemTemplate>
    Table Table2=(Table)e.Item.FindControl("Table1");
    TableRow tRow = new TableRow();
    Table2.Rows.Add(tRow);
    TableCell tCell = new TableCell();
    tCell.Text="ghghh";
    tRow.Cells.Add(tCell);