Re: Format grid column to display "" instead of datetime DBNull (1
- From: Chris <no@xxxxxxxx>
- Date: Thu, 21 Jul 2005 11:40:13 -0400
Carlos Lozano wrote:
Hi Chris,
The error is at runtime. It says "object not set to an instance". I know the grid is not the problem as I can see it after it is populated.
I think it refers to the TableStyles object within the Grid. I Added the following line to verify:
int nStyles = oGrid.TableStyles.Count;
nStyles value is zero. I was expecting a value of 1 as the grid was populated from a table.
Just in case you are wondering, the column formatting setGridColumnStyle() is called after the grid is populated.
Any Ideas?
Thank you,
Carlos Lozano
"Chris" wrote:
Carlos Lozano wrote:
Hello Folks!
I have a grid that populates from a table on SQL Server. All datetime with DBNull value show 1/1/1900 12:00AM ... Instead of just blank ("").
I found a document with the following code, but didn't work.
public void setGridColumnStyle() { DataGridColumnStyle newColStyle; newColStyle = oGrid.TableStyles[0].GridColumnStyles[0]; newColStyle.NullText = ""; }
I tried to customize it to my needs as below:
public void setGridColumnStyle(ref System.Windows.Forms.Grid oGrid, string sTable, string sColumn)
{
DataGridColumnStyle newColStyle;
newColStyle = oGrid.TableStyles[sTable].GridColumnStyles[sColumn];
newColStyle.NullText = "";
}
I always got an error on second line.
I will appreciate any help to do this.
Carlos Lozano www.caxonline.net
What is the error? Is the error at runtime or design time...
Chris
If newColStyle = oGrid.TableStyles[0].GridColumnStyles[0]; works and newColStyle returns something and oGrid.TableStyles[sTable].GridColumnStyles[sColumn]; returns nothing then the names you are passing in for either sTable or sColumn is returning nothing. Most likely sTable is the issue.
obj Object = oGrid.TableStyles[sTable];
Run that line of code and see if obj is set to null; if it does it means that name of your tablestyle isn't equal sTable.
oGrid.TableStyles[0].TableName ??? there is some method that will give you the name of your tablesytle, I don't know what it is called off the top of my head.
hope it helps. Chris .
- Follow-Ups:
- Re: Format grid column to display "" instead of datetime DBNull (1
- From: Carlos Lozano
- Re: Format grid column to display "" instead of datetime DBNull (1
- References:
- Format grid column to display "" instead of datetime DBNull (1/1/1
- From: Carlos Lozano
- Re: Format grid column to display "" instead of datetime DBNull (1/1/1
- From: Chris
- Re: Format grid column to display "" instead of datetime DBNull (1
- From: Carlos Lozano
- Format grid column to display "" instead of datetime DBNull (1/1/1
- Prev by Date: Re: BeginInvoke async callback
- Next by Date: Re: Dynamically create COM objects in C#
- Previous by thread: Re: Format grid column to display "" instead of datetime DBNull (1
- Next by thread: Re: Format grid column to display "" instead of datetime DBNull (1
- Index(es):
Relevant Pages
|