Hi
I am having a problem with the order of the columns in my data grid. I have set the order I want in the data grid property Edit Columns. When I run the project 2 columns are way out of position. I tried to move the out of position column using column order but it is ignored. I then tried coding the position using event private void GridDisplayOrder(). I get the message object reference not set to an instance of an object. Not sure how to get around this error. Here is the event I use
private void GridDisplayOrder()
{
Grid_Property.Columns["pContract_NO"].DisplayIndex = 0;
Grid_Property.Columns["pProperty_ID"].DisplayIndex = 1;
Grid_Property.Columns["pVersion"].DisplayIndex = 2;
etc
etc
any assistance would be appreciated
Komal PatelPosted Jan 8, 2009, 11:41 PM
In DatatGrid by default AutoGenerateColumn is set to true so when ever you assign dataset as datasource it will display columns in the same order as they were retrieved from database
So to fix their order you have to go for tamplate or bound fields
Here what u hv to do :
1. Set AutoGenerateColumn of Datagrid to False
2. Generate bound feilds for each column in dataset
3. If you want to use controls other than label to bind or diaply then use template feild
4. finally assign dataset to grid in pageload
here is sample for grid
//Code for your control