
Signature
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
The example shows connecting to a table, but I'm connecting to a SP.
I get the error, "Object reference not set to an instance of an object."
DataGridColumnStyle colStyle4 = new
DataGridTextBoxColumn();
dgts.GridColumnStyles.Add(colStyle4);
dgts.GridColumnStyles[4].Width = 75;
DataGridTextBoxColumn myGridTextBoxColumn =
(DataGridTextBoxColumn)dgPrivileges.TableStyles["dbo.SALES_REVENUE"].GridColumnStyles["GROSS_FEE_AMOUNT"];
myGridTextBoxColumn.Format = "c";
colStyle4.MappingName = dt.Columns[4].ColumnName;
I have also tried using dt.TableName but recieved error, "Cannot convert
type 'string' to 'System.Windows.Forms.DataGridTextBoxColumn'
DataGridTextBoxColumn myGridTextBoxColumn =
(DataGridTextBoxColumn)dt.TableName;
> Hi Cadel,
>
[quoted text clipped - 11 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
"Jeffrey Tan[MSFT]" - 22 Dec 2005 07:55 GMT
Hi Cadel,
Thanks for your feedback.
I think you may have some misunderstanding of winform databinding. DataGrid
will have no relation to do with database, it only can be bound to .Net
data object, such as DataTable, DataSet, ArrayList etc.... So it does not
care whether the data comes from SP or a SQL statement.
Normally, at DataGrid formatting side, you should first correctly get the
DataGridTextBoxColumn reference. The exception you got is
NullReferenceException, so I think myGridTextBoxColumn you got must be a
Null reference, which caused the problem, so please check this to ensure
that it gets the correct DataGridTextBoxColumn valid reference.
Thanks
Best regards,
Jeffrey Tan
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.