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. Advertisements

  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. Advertisements

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. Bob
    Replies:
    0
    Views:
    731
  2. =?Utf-8?B?VGlncm91?=
    Replies:
    0
    Views:
    619
    =?Utf-8?B?VGlncm91?=
    Nov 27, 2004
  3. =?Utf-8?B?VGlncm91?=
    Replies:
    2
    Views:
    5,197
    =?Utf-8?B?VGlncm91?=
    Nov 30, 2004
  4. Ricardo
    Replies:
    2
    Views:
    7,063
    David Alpert
    Apr 11, 2005
  5. =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=

    Dynamically create TemplateColumn

    =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=, Aug 16, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    5,870
    =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=
    Aug 17, 2005
  6. =?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:
    1,029
    =?Utf-8?B?UGV0ZSBNb3Nz?=
    Apr 8, 2006
  7. Jules Dekker

    Dynamically created TemplateColumn does not raise SortCommand

    Jules Dekker, Feb 13, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    223
    Jules Dekker
    Feb 13, 2004
  8. Ricardo
    Replies:
    2
    Views:
    294
    David Alpert
    Apr 11, 2005
Loading...