Lost columns in datagrid

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.
 
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.
 
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...
 
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.
 
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
 
Back
Top