DataBinder.Eval

  • Thread starter Thread starter Hyrum Mortensen
  • Start date Start date
H

Hyrum Mortensen

Hi,

I want to use a column index instead of name to get the value of a
field:

Instead of:
DataBinder.Eval(Container.DataItem, "config")
I want to do something like:
DataBinder.Eval(Container.DataItem,
Container.DataItem.Table.Columns(1).ColumnName)

The above index method was suggested by a previous post, but I get a
compilation error:
CS0117: 'object' does not contain a definition for 'Table'


Any ideas?


Thanks
 
Hyrum said:
Hi,

I want to use a column index instead of name to get the value of a
field:

Instead of:
DataBinder.Eval(Container.DataItem, "config")
I want to do something like:
DataBinder.Eval(Container.DataItem,
Container.DataItem.Table.Columns(1).ColumnName)

The above index method was suggested by a previous post, but I get a
compilation error:
CS0117: 'object' does not contain a definition for 'Table'

The DataItem property returns a plain-old object. You'll need to cast
it into the object type that has a Table property to get access to the
Table property. Something similar to the following (untested) code:

DataBinder.Eval( ((DataRow)
Container.DataItem).Table.Columns[1].ColumnName);

Note: change the (DataRow) cast to match whatever type is really being
returned by the DataItem property.
 
The type returned is DataRowView, which doesn't have a memeber function
named "Table." Any ideas?
 
hyrum said:
The type returned is DataRowView, which doesn't have a memeber function
named "Table." Any ideas?

Maybe

DataBinder.Eval( ((DataRowView)
Container.DataItem).Row.Table.Columns[1].ColumnName);
 
Back
Top