datagrid columns programatically

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
 
A

AW

You must use a TemplateColumn for this, not a DataBound column. A DataBound
column expects a field name (column or property), not a formula.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top