Click here to Skip to main content
15,913,685 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have bind Two Database Fields in my WPF TextBox that are FirstName and LastName in a same text box.
and in my table i have person ID as well.
So how can i select only First Name from the TextBox?
or is it possible to get first name of the person by PersonID?
Please help me out.
Posted
Comments
stibee 31-Jul-15 7:08am    
Maybe you should some code. How you model looks like? And the view?
Abdul Imran 31-Jul-15 7:55am    
var brand_qry = (from pd in SvarkWindow.prodlist
join pu in SvarkWindow.produnitslist on pd.Product_id equals pu.Product_id
where pu.position > 0
select pd.Product_name + " " + pd.Manufacturer).Distinct().ToList();


foreach (string item in brand_qry)
{
if (!string.IsNullOrEmpty(Search_txt1.Text))
{
if (item.StartsWith(typedString, StringComparison.CurrentCultureIgnoreCase))
{
autoList.Add(item);
}
}
}


And then i am filling the listBox

if (autoList.Count > 0)
{
lbSuggestion.ItemsSource = autoList;
lbSuggestion.Visibility = Visibility.Visible;
}
else if (Search_txt.Text.Equals(""))
{
lbSuggestion.Visibility = Visibility.Collapsed;
lbSuggestion.ItemsSource = null;
}
else
{
lbSuggestion.Visibility = Visibility.Collapsed;
lbSuggestion.ItemsSource = null;
}
}

But later i am unable to access the first field that is "pd.Product_name" and i am getting both field values .
so help me out of it.

1 solution

You can achieve that with following changes.
bind model instead of string which has properties firstname and lastname.
in xaml using multibinding you can concat this two values.

from model later you can access firstname.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900