Create TemplateColumn Dynamically

Discussion in 'ASP .Net Web Controls' started by Lubos, Jun 30, 2004.

  1. Lubos

    Lubos Guest

    Hi,
    I'd like to create TemplateColumn at runtime.
    I want to add an Control (like Button,..) to this column.
    Is there any example how to this this?

    Thanks in advance,
    Lubos

    PS:
    I can do this with the BountColumn:
    BoundColumn bc2 = new BoundColumn();
    bc2.DataField = "product_nm";
    bc2.HeaderText = "Number";
    myDataGrid.Columns.Add(bc2);
    Lubos, Jun 30, 2004
    #1
    1. Advertising

  2. Lubos

    Teemu Keiski Guest

    Hi,

    you'd need to create templates

    a) by loading them from user control files (Page.LoadTemplate method)
    or
    b) create templates by having classes that implement ITemplate interface.
    See an article about it here:
    http://www.tripleasp.net/tutorial.aspx?NavID=27

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist
    http://blogs.aspadvice.com/joteke



    "Lubos" <> wrote in message
    news:...
    > Hi,
    > I'd like to create TemplateColumn at runtime.
    > I want to add an Control (like Button,..) to this column.
    > Is there any example how to this this?
    >
    > Thanks in advance,
    > Lubos
    >
    > PS:
    > I can do this with the BountColumn:
    > BoundColumn bc2 = new BoundColumn();
    > bc2.DataField = "product_nm";
    > bc2.HeaderText = "Number";
    > myDataGrid.Columns.Add(bc2);
    Teemu Keiski, Jun 30, 2004
    #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. =?Utf-8?B?VGlncm91?=
    Replies:
    0
    Views:
    515
    =?Utf-8?B?VGlncm91?=
    Nov 27, 2004
  2. =?Utf-8?B?VGlncm91?=
    Replies:
    2
    Views:
    4,892
    =?Utf-8?B?VGlncm91?=
    Nov 30, 2004
  3. =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=

    Dynamically create TemplateColumn

    =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=, Aug 16, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    5,638
    =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=
    Aug 17, 2005
  4. =?Utf-8?B?UGV0ZSBNb3Nz?=

    Maintaining state with a dynamically created TemplateColumn

    =?Utf-8?B?UGV0ZSBNb3Nz?=, Apr 5, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    911
    =?Utf-8?B?UGV0ZSBNb3Nz?=
    Apr 8, 2006
  5. Jules Dekker

    Dynamically created TemplateColumn does not raise SortCommand

    Jules Dekker, Feb 13, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    131
    Jules Dekker
    Feb 13, 2004
Loading...

Share This Page