Lost columns in datagrid

G

Guest

Hello,

I have a datagrid with a checkbox column created in VS. The user can filter
the data
and obtain a grid (with dimanics columns : AutoGenerateColumns=false) in
which he selects the lines. When he submits the query, the datagrid
contains only the first column. Where are my others columns ???

Thank you for your help
 
J

JohnH

How are the other columns added to the grid? You may need to enable
viewstate for the datagrid, or call the DataBind method to regenerate
the other columns.
 
G

Guest

Hello,

In fact, the user can choose several options of filters what creates a first
datagrid in which I add the columns.
System.Web.UI.WebControls.BoundColumn bc = new BoundColumn();
bc.HeaterText = ........
....
The user obtains the grid with all the data.Then he selects the lines and
with the return I do not have any more the columns...
I will test viewstate.
 
G

Guest

EnableViewState=true does not give more results :(
I don't understand : when I click on my button, the page sends the datagrid
with the first column (with checkbox correctly set) but the others columns
don't be returned.
Is this because AutoGenerateColumns=false ? However, I have to create my
columns dynamically...
 
J

JohnH

Ah, I see. In order for the the "magic" ViewState reconstructor to
work, the BoundColumn definitions must have been added to the DataGrid
before the ViewState is processed, and the ViewState processor has to
be able to find them (the BoundColumns) by ID. So:

1. Add the BoundColumns to the DataGrid in the Page.OnInit method; and
2. Make sure you set the ID of each control in the columns.

HTH,

John H.
 
G

Guest

Thanks for your help JohnH.

In fact I make already Post after having defines the columns…
When I apply the ViewState method to the datagrid, I have an error: the
object cannot be serializable.
I will correct that but when I will recover my datagrid customer,
how to make for concerver the column with checkbox (with their values) ?

Reg
 

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,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top