datagrid columns programatically

  • Thread starter Thread starter Michelle Stone
  • Start date Start date
M

Michelle Stone

Hi

I use the following code to add a column to a datagrid
programatically

col = new BoundColumn ();
col.HeaderText = "Agency";
col.DataField = "gridGetIsAgency (DataBinder.Eval
Container, 'DataItem.Agency').ToString ())";

approvalGrid.Columns.Add (col);

"gridGetIsAgency" is a function that evaluations the
value of the AGENCY field and returns a value
appropriately

public string gridGetIsAgency (string sValue)
{
return "return something for now";
}

I get the following error:

====
A field or property with the name 'gridGetIsAgency
(DataBinder.Eval (Container, 'DataItem.Agency').ToString
())' was not found on the selected datasource
====

Now, I have confirmed that the field AGENCY exists. What
else could be the problem? Thanks
 
You must use a TemplateColumn for this, not a DataBound column. A DataBound
column expects a field name (column or property), not a formula.
 
Back
Top