> "EmilH" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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
|