views:

628

answers:

2

I am trying to boild my treeview at runtime from a DataTable that is returned from a LINQ query. The Fields returned are:

NAME = CaseNoteID | ContactDate | ParentNote TYPE = Guid | DateTime | Guid

The ParentNote field matches a entry in the CaseNoteID column. The Select(filter) is giving me a runtime error of Cannot find column [ea8428e4]. That alphanumeric is the first section of one of the Guids. When I step thru my code filter = "ParentNote=ea8428e4-1274-42e8-a31c-f57dc2f189a4"

What am I missing?

var tmpCNoteID = dr["CaseNoteID"].ToString();
                var filter = "ParentNote="+tmpCNoteID;

                DataRow[] childRows = cNoteDT.Select(filter);
+2  A: 

Try enclosing the GUID with single quotes:

var filter = "ParentNote='"+tmpCNoteID+"'";
WOW! Do I feel like an idiot!Thanks! Worked like a charm!
Refracted Paladin
+1  A: 

this should work :

   var tmpCNoteID = dr["CaseNoteID"].ToString();
                var filter = "ParentNote=\""+tmpCNoteID+"\"";

                DataRow[] childRows = cNoteDT.Select(filter);
Adinochestva