Programatically add column

Discussion in 'ASP .Net Datagrid Control' started by Audun Simonsen, Feb 2, 2004.

  1. Hi.

    My problem is how to add several columns with a checkbox programatically to
    a datagrid.

    Anybody with some pointers?


    -as
    Audun Simonsen, Feb 2, 2004
    #1
    1. Advertising

  2. Saravana [MVP], Feb 3, 2004
    #2
    1. Advertising

  3. "Saravana [MVP]" <> wrote in message
    news:%...
    > Check out this articles,
    > Creating Datagrid Templated Columns Dynamically
    > http://www.dotnetbips.com/displayarticle.aspx?id=84
    > http://www.dotnetbips.com/displayarticle.aspx?id=85
    >
    >


    Thanks, those examples helped me a lot, and I'm now able to add some
    columns.

    But, how can I make those columns persistant? They dissapear when I do a
    postback of the page.

    I add the column in the Page_Load method, according to the example in
    http://www.dotnetbips.com/displayarticle.aspx?id=85:


    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    If Not Page.IsPostBack Then
    Dim tc1 As TemplateColumn

    tc1 = New TemplateColumn()
    tc1.ItemTemplate = New CTemplateColumn("Include")
    tc1.HeaderText = "First name"
    dgValues.Columns.Add(tc1)

    tc1 = Nothing

    PopulatePrdGruppeLev0()
    End If
    End Sub


    The datagrid, dgValues, gets populated in the method
    PopulatePrdGruppeLev0().




    -as
    Audun Simonsen, Feb 3, 2004
    #3
    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. Hai Nguyen
    Replies:
    0
    Views:
    393
    Hai Nguyen
    Jan 16, 2004
  2. Dan Hartshorn

    Programatically Change Datagrid column type?

    Dan Hartshorn, Apr 13, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,020
    Dan Hartshorn
    Apr 13, 2004
  3. Random
    Replies:
    1
    Views:
    4,620
    Random
    Nov 19, 2004
  4. Kbalz
    Replies:
    2
    Views:
    1,327
    Kbalz
    Oct 4, 2007
  5. EdwardH
    Replies:
    0
    Views:
    498
    EdwardH
    Oct 12, 2008
Loading...

Share This Page