Using C #, WPF, .NET 4.5 In my program, I am trying to populate a TextBox value from a database. The value is obtained by the LINQ operator. I tried all different things like To.String() and Console.WriteLine() etc. If you can find a way to make this work amazing, if you can find a better way to select the data and display it, I will be interested too. C # code:
private AuroraEntities auroraContext = null; private void LoadTB() { this.auroraContext = new AuroraEntities(); ObjectQuery<Inventory> inventories = auroraContext.Inventories; string name = ingNameCB.SelectedValue.ToString(); var queryResult = (from q in inventories where q.InventoryName == name select q); textBox1.DataContext = queryResult.ToString(); }
XAML:
<TextBox Height="23" HorizontalAlignment="Left" Margin="70,186,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" Text="{Binding Path=InventoryName, Mode=TwoWay}"
thanks!
source share