PC Review


Reply
Thread Tools Rate Thread

column.expression

 
 
EmilH
Guest
Posts: n/a
 
      4th May 2007
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


 
Reply With Quote
 
 
 
 
EmilH
Guest
Posts: n/a
 
      4th May 2007
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" <(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();
>
>
>
> Thanks.
>
> Emil
>
>



 
Reply With Quote
 
Jesse Houwing
Guest
Posts: n/a
 
      4th May 2007
> "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
 
Reply With Quote
 
EmilH
Guest
Posts: n/a
 
      4th May 2007
Thanks Jesse!
"Jesse Houwing" <(E-Mail Removed)> wrote in message
news:%23%(E-Mail Removed)...
>> "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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to use expression to define a column from another text column? access-green Microsoft Access Queries 1 12th Oct 2005 09:39 PM
Expression Column based on another expression column - Is this possible? APops Microsoft ADO .NET 3 27th Apr 2005 10:13 PM
¿¿help in column expression :(( perspolis Microsoft C# .NET 2 21st Feb 2005 12:54 PM
DataSet.Merge with Column.Expression. expression not =?Utf-8?B?R2llZHJpdXM=?= Microsoft ADO .NET 4 12th Jan 2005 09:45 AM
Expression column with ABS Kartic Microsoft VB .NET 2 23rd Sep 2003 10:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:39 AM.