column.expression

  • Thread starter Thread starter EmilH
  • Start date Start date
E

EmilH

Hi.

The following line gives me exception 'Cannot find column Motherboard'
(where ;Motherboard = itemsLB.SelectedItem.ToString())

itemsTable.Columns["Name"].Expression = itemsLB.SelectedItem.ToString();



Thanks.

Emil
 
I changed the line to this:
itemsTable.Columns["Name"].Expression = "Name = '" +
itemsLB.SelectedItem.ToString() + "'";



I get an exception of Circular reference. How can I filter the table for a
criteria?
 
EmilH said:
Hi.

The following line gives me exception 'Cannot find column Motherboard'
(where ;Motherboard = itemsLB.SelectedItem.ToString())

itemsTable.Columns["Name"].Expression = itemsLB.SelectedItem.ToString();
* EmilH wrote, On 4-5-2007 10:04:
I changed the line to this:
itemsTable.Columns["Name"].Expression = "Name = '" +
itemsLB.SelectedItem.ToString() + "'";

I get an exception of Circular reference. How can I filter the table for a
criteria?

You basically have two options here:

1) Use a Dataview
Dataview dv = new DataView(itemsTable, "Name = \"" +
itemsLB.SelectedItem.ToString(),"");

2) User Table.Select() to get the rows that match the criteria:
DataRow[] rows = itemsTable.Select(Name = \"" +
itemsLB.SelectedItem.ToString());

The Expression Property you're working with is not used to filter a
table, but to dynamically create a fieldvalue based on other data in the
table.

Jesse Houwing
 
Thanks Jesse!
Jesse Houwing said:
EmilH said:
Hi.

The following line gives me exception 'Cannot find column Motherboard'
(where ;Motherboard = itemsLB.SelectedItem.ToString())

itemsTable.Columns["Name"].Expression = itemsLB.SelectedItem.ToString();
* EmilH wrote, On 4-5-2007 10:04:
I changed the line to this:
itemsTable.Columns["Name"].Expression = "Name = '" +
itemsLB.SelectedItem.ToString() + "'";

I get an exception of Circular reference. How can I filter the table for a
criteria?

You basically have two options here:

1) Use a Dataview
Dataview dv = new DataView(itemsTable, "Name = \"" +
itemsLB.SelectedItem.ToString(),"");

2) User Table.Select() to get the rows that match the criteria:
DataRow[] rows = itemsTable.Select(Name = \"" +
itemsLB.SelectedItem.ToString());

The Expression Property you're working with is not used to filter a table,
but to dynamically create a fieldvalue based on other data in the table.

Jesse Houwing
 

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

Back
Top