Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a textbox which need to bind with database value
Like,i have a text box a combo box and a button.Mr X selects a value(say Employee No) from combo box and click the button.Based on the value(say Employee No) the associated name should fill in the text box.How can i achieve?

What I have tried:

<TextBox Template="{StaticResource TextBoxBaseControlTemplate}" x:Name="txttitle1" HorizontalAlignment="Left" Height="30" Margin="578,22,0,0" TextWrapping="Wrap" Text="{Binding PODetail.PO_TITLE1,Mode=TwoWay}" VerticalAlignment="Top" Width="152"/>

Below is the get/set of my model class

    public PurchaseOrderModel podetail = new PurchaseOrderModel();
        public PurchaseOrderModel PODetail
        {
            get { return podetail; }
            set { podetail = value; OnPropertyChanged("PODetail"); }
        } 
       
  PODetail.PO_TITLE1 = pom.PO_TITLE1;-->In this the value sets to text box in viewmodel but not reflecting to View
Posted
Updated 21-Mar-18 20:26pm
Comments
Richard Deeming 20-Feb-18 15:16pm    
Your PurchaseOrderModel class needs to implement INotifyPropertyChanged.
Member 12008812 20-Feb-18 22:34pm    
Yes,I failed to implement that.Now,Its working

1 solution

I believe your problem is that you set the value of PO_TITLE1 after the binding and the class PODetail has been set. You will have to implement the INotifyPropertyChanged in the PurchaseOrderModel class and trigger the PropertyChanged Event when the PO_TITLE1 value is changed.
 
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