Dynamically Adding Boundfields + Sorting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ami

    #1

    Dynamically Adding Boundfields + Sorting

    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(addColu mns). 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!

Working...