Here's the situation: This is for a WPF app that uses C#.
When a user wants to look at a list of customers, he/she begins entering the name in a textbox. The textchanged event uses the input text to define the where clause of a LINQ statement that filters the list. I currently have two such text boxes that run essentially the same code, but I cannot reduce that code to a single function - I'll be using customer lists in a bunch more places.
Here's a bit of the code:
private void CustomerListFil ler(object sender, TextChangedEven tArgs e)
{
string SearchText;
FrameworkElemen t feSource = e.Source as FrameworkElemen t;
SearchText = sender.Text;
var fillCustList = from c in dbC.Customers
where c.CustomerName. StartsWith(Sear chText)
orderby c.CustomerName
select new
{
c.CustomerID,
c.CustomerName
};
followed by a switch statement.....
The bold, italicized line is the problem. I can't figure out how get at the text value of the sender to use in the StartsWith function.
The error message is:
Error 1 'object' does not contain a definition for 'Text' and no extension method 'Text' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Any help would be great...I don't think I even know what the problem is...
When a user wants to look at a list of customers, he/she begins entering the name in a textbox. The textchanged event uses the input text to define the where clause of a LINQ statement that filters the list. I currently have two such text boxes that run essentially the same code, but I cannot reduce that code to a single function - I'll be using customer lists in a bunch more places.
Here's a bit of the code:
private void CustomerListFil ler(object sender, TextChangedEven tArgs e)
{
string SearchText;
FrameworkElemen t feSource = e.Source as FrameworkElemen t;
SearchText = sender.Text;
var fillCustList = from c in dbC.Customers
where c.CustomerName. StartsWith(Sear chText)
orderby c.CustomerName
select new
{
c.CustomerID,
c.CustomerName
};
followed by a switch statement.....
The bold, italicized line is the problem. I can't figure out how get at the text value of the sender to use in the StartsWith function.
The error message is:
Error 1 'object' does not contain a definition for 'Text' and no extension method 'Text' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Any help would be great...I don't think I even know what the problem is...
Comment