Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Design Time vs Run Time DataGrid (http://www.velocityreviews.com/forums/t95811-design-time-vs-run-time-datagrid.html)

=?Utf-8?B?cmtibmFpcg==?= 02-01-2005 07:35 PM

Design Time vs Run Time DataGrid
 
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>
//===============================================


Karl Seguin 02-01-2005 08:11 PM

Re: Design Time vs Run Time DataGrid
 
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" <rkbnair@discussions.microsoft.com> wrote in message
news:B9A130B6-67A0-48F0-8C4D-0C5C2F96C6F0@microsoft.com...
> 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>
> //===============================================
>





All times are GMT. The time now is 06:35 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.