Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Design Time vs Run Time DataGrid

Reply
Thread Tools

Design Time vs Run Time DataGrid

 
 
=?Utf-8?B?cmtibmFpcg==?=
Guest
Posts: n/a
 
      02-01-2005
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>
//===============================================

 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      02-01-2005
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>
> //===============================================
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Const Static variables set at run time and a design question. Jim C++ 5 09-30-2009 07:57 AM
Run-time template list definition / Run-time variable type definition Pierre Yves C++ 2 01-10-2008 02:52 PM
Run/design time packages Peter Morris [Droopy Eyes Software] ASP .Net Building Controls 1 09-09-2004 11:17 AM
Unlikely differences between design time and run time. Tzury Bar Yochay ASP .Net 3 11-29-2003 08:56 AM
Determining control behaviour at design-time/run-time Paul Cook ASP .Net 0 11-06-2003 09:17 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57