Tied Up In Knots ASP.NET DataGrid

N

New Bee

This may or may not be a simple problem to solve, but to me its seesm
complex, so I will try and be as succinct as possible.

The Scenario
-------------
I am using a DataGrid to display data from different table stored in an SQL
Database. Depending on the Table, I bind the data to the grid which
successfly allows me to display and edit the contents. So far so good.
However, I want to be able to alter the css styles for the header depending
on the table due to widths etc.

Now presently the grid is set to allow the columns to be built
automatically, and this works ok, the only problem is that those columns are
not available programatically as they are built on the fly when the page is
redered. So you think to yourself OK, we will add the bound columns
programatically and set things like the DataField, Header.cssClass etc etc.
Right this works fine for display, but as soon as you want to PostBack, then
you get into difficulty, because when you add the bound columns
programatically, you loose the items you sent during postback.

I have tried saving the column collection and then re-instatingi it during
postback, but you lose the data originallysent back, and so cannot access
any controls in the cells etc.

Im sure someone must have solved this, any help would be appreciated.


Many Thanks
 

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,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top