SortExpression makes SortCommand event not to trig

G

Guest

Hi!

When I add a bound column programatically, like:

BoundColumn bc = new BoundColumn();
bc.DataField = "myField";
bc.SortExpression = "myField";
myGrid.Columns.Add(bc);

the SortCommand event does not trig at all!

If I replace the code whith the markup syntax in the ascx file, it works
fine. I've google around but the only solution to the problem seemes to be
moving the code to Page_Init.

This is not possible because at that time I dont know the structure of the
table. Depending on a selection in a dropdown, i get diffrent datatables to
bind with the grid. The selectedindexchanged event on the dropdown will not
fire until much later in execution, so in Page_Init I wouldn't know what was
selected yet. Furthermore i cant understand what Page_Init has to do with all
of this.

I'm confused, any ideas?

Thanks,
Paul
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top