Rk:
Absolutely, take a look at the Page.LoadTemplate() function. It behaves a
lot like the Page.LoadControl, but instead of returning an instance of
Control it returns an instance of Itemplate, which can be assigned to the
datagrid's ItemTemplate and/or EditTemplate property. Other than that it
works a lot like a user control.
There are all types of resource (google search for Page.LoadTemplate might
be your best bet):
http://msdn.microsoft.com/library/de...vercontrol.asp
http://www.aspdotnetheaven.com/Code/...icTemplate.asp
I think instead of using Container.DataItem you simply use Container
Happy Hunting
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"rkbnair" <> wrote in message
news:B9A130B6-67A0-48F0-8C4D-...
> Is it possible to define the <ItemTemplate> and <EditItemTemplate> in
> DataGrid programitically at run-time?
>
> The sample definition is as follows:
>
> //===============================================
> <asp:TemplateColumn HeaderText="TestColumnLabel">
>
> <ItemTemplate>
> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container,
> "DataItem.str_pblock") %>'>
> </asp:Label>
> </ItemTemplate>
>
> <EditItemTemplate>
> <asp:TextBox runat="server" Text='<%# DataBinder.Eval(Container,
> "DataItem.str_pblock") %>'>
> </asp:TextBox>
> </EditItemTemplate>
>
> </asp:TemplateColumn>
> //===============================================
>