Groups | Blog | Home
all groups > asp.net datagrid control > october 2003 >

asp.net datagrid control : Help with DataColumn.Expression


Lee Franke
10/13/2003 6:49:33 PM
I'm trying to implement Child.ColumnName as in this example.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatacolumnclassexpressiontopic.asp

I am attempting to use the line.
DataColumn.Expresson = "Child.AdminName";

I get the error "Cannot interpret token 'Child' at position 1".

The DataRelation does exist.

Has anyone done this successfully before?

Thanks,

lee franke

Lee Franke
10/14/2003 9:49:16 AM
Here ya go

Code that sets up the relationship
DataColumn parentCol;

DataColumn childCol;

parentCol = dsResults.Tables["People"].Columns["adminID"];

childCol = dsResults.Tables["Admins"].Columns["employeeID"];

DataRelation myRptRelation = new
DataRelation("AdminNames",parentCol,childCol,false);

dsResults.Relations.Add(myRptRelation);



Code that adds the column
//now add a NEW column that will populate the admin's name
DataColumn cName = new DataColumn();

cName.DataType = System.Type.GetType("System.String");

cName.ColumnName = "adminName";

cName.Expression = "Child.displayName" ;

dsResults.Tables["People"].Columns.Add(cName);

Thanks,

lee franke


[quoted text, click to view]

Prasad
10/14/2003 3:17:29 PM
Hi

Please post your code so that it will be easy to fix.

Prasad

[quoted text, click to view]
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemdatadatacolumnclassexpressiontopic.asp
[quoted text, click to view]

AddThis Social Bookmark Button