Datagrid Custom table/column style...

D

Darryn Ross

Hi,

I am trying to display a long integer value from my access table in a
Datagrid with a custom style applied to it and the value is not coming
through correct??

database value = 0.00000 %
datagrid value = 0.00 %

How do i get my column style to display the details as they are in the
table???...

the columns in question are the % columns...

my code is as follows.....


string[] strHeaderText = new string[] {"Partner ID", "Partner Name",
"Current Year %", "Last Year %", "Two Years Ago %", "Three Years Ago %",
"Four Years Ago %"} ;

int[] iWidth = new int[] {70, 150, 95, 95, 95, 95, 95} ;

// Add a GridTableStyle and set the MappingName

// to the name of the DataTable.

DataGridTableStyle TSPartner = new DataGridTableStyle() ;

TSPartner.MappingName = "tblPartner" ;

DataTable dt = PartDs.Tables["tblPartner"] ;

// Add a GridColumnStyle and set the MappingName

// to the name of a DataColumn in the DataTable.

// Set the HeaderText and Width properties.

for(int i = 0; i < 7; i++) {

DataGridTextBoxColumn CColStyle = new DataGridTextBoxColumn() ;

CColStyle.MappingName = dt.Columns.ColumnName ;

CColStyle.HeaderText = strHeaderText ;

CColStyle.Width = iWidth ;

CColStyle.ReadOnly = (i == 0) ? true : false ;

if(i == 1) {

dt.Columns.DefaultValue = "" ;

}

else if(i > 1) {

dt.Columns.DefaultValue = 0 ;

CColStyle.Format = "P" ;

}

TSPartner.GridColumnStyles.Add(CColStyle) ;

CColStyle.Dispose() ;

}

TSPartner.AllowSorting = false ;

dgPartners.TableStyles.Add(TSPartner) ;





Regards

Darryn
 

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

Top