Design Time vs Run Time DataGrid

Discussion in 'ASP .Net' started by =?Utf-8?B?cmtibmFpcg==?=, Feb 1, 2005.

  1. 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>
    //===============================================
     
    =?Utf-8?B?cmtibmFpcg==?=, Feb 1, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?cmtibmFpcg==?=

    Karl Seguin Guest

    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/d...umnsdynamicallyindatalistwebservercontrol.asp
    http://www.aspdotnetheaven.com/Code/Jan2003/DynamicTemplate.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:...
    > 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, Feb 1, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Cook
    Replies:
    0
    Views:
    478
    Paul Cook
    Nov 6, 2003
  2. Tzury Bar Yochay
    Replies:
    3
    Views:
    504
    Jacob Yang [MSFT]
    Nov 29, 2003
  3. Pierre Yves
    Replies:
    2
    Views:
    523
    Pierre Yves
    Jan 10, 2008
  4. Jim
    Replies:
    5
    Views:
    452
    James Kanze
    Sep 30, 2009
  5. Peter Morris [Droopy Eyes Software]

    Run/design time packages

    Peter Morris [Droopy Eyes Software], Sep 9, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    206
    John Saunders
    Sep 9, 2004
Loading...

Share This Page