Using C#, WPF, .NET 4.5
In my program, I am trying to populate the value of a TextBox from a database. The value is obtained by a LINQ statement. I've tried all different things such as To.String()
and Console.WriteLine()
etc. If you can figure out a way to make this work that would be awesome, if you can find a better way to select the data and display it, i would be interested in that as well.
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!