Dynamically Adding Boundfields + Sorting

Discussion in 'ASP .Net' started by ami, Apr 25, 2007.

  1. ami

    ami Guest

    Hi everyone,

    I have a question about dynamically adding columns to a gridview.

    Based on user input (after a button click), some columns are being
    added to my gridview.

    What I do:

    OnButtonClick: I call a method that adds the new boundfield
    columns(addColumns). After that, it calls databind on the gridview.
    This works fine.

    However, when I sort a column, the newly added columns disappear. I
    am assuming this is because my method to add the columns is in the
    ButtonClick event and is getting lost on the new databinding.

    My question is - where do I call my addColumns method for sorting?
    How do I modify the OnSorting event to call this method and then do
    the sorting correctly? Currently, I have not implemented the
    OnSorting event. I have just turned sorting on in the gridview and am
    letting the gridview take care of it.

    In addition, am I calling my addColumns method in the correct place
    after the user button click? It can't be called from the OnDataBound
    event - this just causes the gridview to be databound repeatedly.

    Thanks for any help you can provide!
    ami, Apr 25, 2007
    #1
    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. Christina

    How do I Email DetailsView BoundFields

    Christina, Dec 8, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    356
    Christina
    Dec 8, 2006
  2. helveticus

    Localizing BoundFields

    helveticus, Dec 2, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    342
    helveticus
    Dec 2, 2008
  3. JB
    Replies:
    3
    Views:
    1,992
    Alexey Smirnov
    Oct 21, 2009
  4. jonefer

    Dynamically boundfields aren't really dynamic

    jonefer, May 23, 2007, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    748
    jonefer
    May 23, 2007
  5. Pete

    Converting BoundFields from tags to code

    Pete, Sep 17, 2007, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    160
Loading...

Share This Page