use the following code (sorry its in C#)
in Page_Load
DataGrid1.ItemCreated += new
DataGridItemEventHandler(DataGrid1_ItemCreated);
//bind your first grid
DataGrid1.DataSource = data;
DataGrid1.DataBind();
create the following method
private void DataGrid1_ItemCreated(object sender, DataGridItemEventArgs
e)
{
if(e.Item.ItemType == ListItemType.AlternatingItem
|| e.Item.ItemType == ListItemType.Item)
{
//find the control by referencing the col number
//if the template col is in the first col then
//use index 0
DataGrid DataGrid2 =
(DataGrid)e.Item.Cells[0].FindControl("DataGrid2");
//use whatever data source you need
DataGrid2.DataSource = new string[3]{"ab", "cd", "ef"};
DataGrid2.DataBind();
}
}
------ this is the html code
<asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns=False>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:DataGrid ID="DataGrid2" Runat="server"></asp:DataGrid>
<br>
rest of template
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
-----
http://garethjames.blogspot.com/