Dynamically Adding Boundfields + Sorting

A

ami

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,052
Latest member
KetoBeez

Latest Threads

Top