Dynamic DataGrid

Discussion in 'ASP .Net Web Controls' started by CanoeGuy, Aug 29, 2005.

  1. CanoeGuy

    CanoeGuy Guest

    I am wanting to dynamically display different columns in a DataGrid based on
    what item the user chooses. As an example, if the user chooses Item A, I
    want to display column1, column2, and column5. If the user chooses Item B, I
    want to display column1, column2, column8 and column9. The columns that will
    not be displayed to the user are always either Null or 0 (zero). I haven't
    been able to find a working example or a solution anywhere in my research.

    Thanks in advance for the help.
    --
    Joe Goeke
     
    CanoeGuy, Aug 29, 2005
    #1
    1. Advertising

  2. CanoeGuy

    Curt Guest

    This is a BIG question , in that you can configure a DataGrid in so many
    different ways! The right anwser depends on the way you are using the
    DataGrid.

    I almost always solve such questions in the core SQL itself, by writing the
    SQL to match the columns required. Less coding is necessary to bind such
    data to a DataGrid object this way, and just about any SQL you write will
    work.

    If you are creating the DataGrid in code, of if dynamic SQL is not an
    option, then leverage static SQL by adding only the required columns to your
    DataGrid. There are tons of examples of how to do this on the web. Here
    are two starters:
    http://odetocode.com/Articles/218.aspx
    http://www.c-sharpcorner.com/Database/PlayingWithDataGridTA.asp

    Good luck,
    Curt


    "CanoeGuy" <> wrote in message
    news:...
    >I am wanting to dynamically display different columns in a DataGrid based
    >on
    > what item the user chooses. As an example, if the user chooses Item A, I
    > want to display column1, column2, and column5. If the user chooses Item
    > B, I
    > want to display column1, column2, column8 and column9. The columns that
    > will
    > not be displayed to the user are always either Null or 0 (zero). I
    > haven't
    > been able to find a working example or a solution anywhere in my research.
    >
    > Thanks in advance for the help.
    > --
    > Joe Goeke
     
    Curt, Aug 30, 2005
    #2
    1. Advertising

  3. CanoeGuy

    CanoeGuy Guest

    Hi Curt,

    Thanks for your reply. Believe it or not it answers the big question that I
    had of whether I should handle the data in the SQL or in the DataGrid. Can
    you help me on the best way to filter out Null fields in the SQL Statement?
    As long as I can get started, I can do the rest of the research.

    Thanks,

    //Joe
    --
    Joe Goeke


    "Curt" wrote:

    > This is a BIG question , in that you can configure a DataGrid in so many
    > different ways! The right anwser depends on the way you are using the
    > DataGrid.
    >
    > I almost always solve such questions in the core SQL itself, by writing the
    > SQL to match the columns required. Less coding is necessary to bind such
    > data to a DataGrid object this way, and just about any SQL you write will
    > work.
    >
    > If you are creating the DataGrid in code, of if dynamic SQL is not an
    > option, then leverage static SQL by adding only the required columns to your
    > DataGrid. There are tons of examples of how to do this on the web. Here
    > are two starters:
    > http://odetocode.com/Articles/218.aspx
    > http://www.c-sharpcorner.com/Database/PlayingWithDataGridTA.asp
    >
    > Good luck,
    > Curt
    >
    >
    > "CanoeGuy" <> wrote in message
    > news:...
    > >I am wanting to dynamically display different columns in a DataGrid based
    > >on
    > > what item the user chooses. As an example, if the user chooses Item A, I
    > > want to display column1, column2, and column5. If the user chooses Item
    > > B, I
    > > want to display column1, column2, column8 and column9. The columns that
    > > will
    > > not be displayed to the user are always either Null or 0 (zero). I
    > > haven't
    > > been able to find a working example or a solution anywhere in my research.
    > >
    > > Thanks in advance for the help.
    > > --
    > > Joe Goeke

    >
    >
    >
     
    CanoeGuy, Aug 30, 2005
    #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. Rick Glos
    Replies:
    0
    Views:
    648
    Rick Glos
    Jul 8, 2003
  2. Chris Thunell
    Replies:
    3
    Views:
    3,434
    Edward
    Jul 21, 2004
  3. Andreas Klemt
    Replies:
    0
    Views:
    313
    Andreas Klemt
    Oct 8, 2003
  4. Replies:
    0
    Views:
    212
  5. Replies:
    1
    Views:
    337
Loading...

Share This Page