dynamically add columns to datagrid

Discussion in 'ASP .Net' started by wapsiii, Feb 2, 2006.

  1. wapsiii

    wapsiii Guest

    I'm unsure how to best approach this challenge:

    A stored proc returns a dataset where the last four columns have
    dynamic column names [current year - 3], [current year - 2], [current
    year - 1] [current year] (ie. Company, [2003], [2004], [2005],
    [2006]).

    The row values of these last four year columns I could access by their
    position. However, I'd like the datagrid's column's HeaderText to
    assume the column name of the returned dataset.

    How do I do this?
     
    wapsiii, Feb 2, 2006
    #1
    1. Advertising

  2. What about a datagrid with AutoGenerated columns?

    Eliyahu

    "wapsiii" <> wrote in message
    news:...
    > I'm unsure how to best approach this challenge:
    >
    > A stored proc returns a dataset where the last four columns have
    > dynamic column names [current year - 3], [current year - 2], [current
    > year - 1] [current year] (ie. Company, [2003], [2004], [2005],
    > [2006]).
    >
    > The row values of these last four year columns I could access by their
    > position. However, I'd like the datagrid's column's HeaderText to
    > assume the column name of the returned dataset.
    >
    > How do I do this?
     
    Eliyahu Goldin, Feb 2, 2006
    #2
    1. Advertising

  3. Hi,
    Good news is that DataGrid will automatically add and modify the column
    header at runtime using the changed column header as long as you check the
    "create columns automatically at runtime" checkbox on Datagrid's
    PropertyBuilder dialog and use a plain (not strongly typed) dataset as its
    datasource.

    --
    _________________________
    Kostas Pantos [MCP]
    http://kostas.pantos.name


    "wapsiii" wrote:

    > I'm unsure how to best approach this challenge:
    >
    > A stored proc returns a dataset where the last four columns have
    > dynamic column names [current year - 3], [current year - 2], [current
    > year - 1] [current year] (ie. Company, [2003], [2004], [2005],
    > [2006]).
    >
    > The row values of these last four year columns I could access by their
    > position. However, I'd like the datagrid's column's HeaderText to
    > assume the column name of the returned dataset.
    >
    > How do I do this?
    >
     
    =?Utf-8?B?S29uc3RhbnRpbm9zIFBhbnRvcw==?=, Feb 2, 2006
    #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. John Ruiz
    Replies:
    6
    Views:
    3,583
    John Ruiz
    Jan 5, 2004
  2. keithb
    Replies:
    1
    Views:
    14,885
    Bruno Piovan
    Mar 30, 2006
  3. GP

    How to add columns dynamically using Datgrid in C#

    GP, Aug 27, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    124
  4. rob thomson
    Replies:
    0
    Views:
    261
    rob thomson
    Sep 4, 2003
  5. ton
    Replies:
    2
    Views:
    206
    Alvin Bruney [MVP]
    Feb 11, 2004
Loading...

Share This Page