knji

I want to test for the type in each cell of my dataset. Object is currently at tempTableRow[tempTableCol].

I have tried

if (tempTableRow[tempTableCol].GetType is String)

{ //do this}

I have also tried typeof(tempTableRow[tempTableCol]) but somehow the format is wrong!

Maybe it is getting too late.

Basically, I have a table whoes rows contain integers, strings and nulls, and I want to do the following test:

If table cell is of type string AND string value equals "Y"

{do something}

Any help would be appreciated.

Thanks,

Klaus



Re: Visual C# General How do I test for an object type?

Andrej Tozon

Hi,

to test datatable's cells for their data types, try accessing their column definitions through their owner Table:

Code Snippet

if (tempTableRow.Table.Columns[tempTableCol].DataType == typeof(string) && ((string)tempTableRow[tempTableCol]) == "Y")

{

MessageBox.Show("Do something");

}

Andrej






Re: Visual C# General How do I test for an object type?

knji

Thank You.