如果表A1中的值buttockno是字符串类型,则可以使用以下代码。 如果表Al中的buttockno的值为数字怎么办?
<Window x:Class="DamDarYar_IDMS.Window4"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DamDarYar_IDMS"
mc:Ignorable="d"
Title="Window4" Height="300" Width="300">
<Grid>
<TextBox x:Name="textBox" HorizontalAlignment="Left" Height="23" Margin="151,44,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120" TextChanged="textBox_TextChanged"/>
<DataGrid x:Name="dataGrid" HorizontalAlignment="Left" Margin="60,82,0,0" VerticalAlignment="Top" Height="112" Width="211"/>
</Grid>
private void textBox_TextChanged(object sender, TextChangedEventArgs e)
{
IDMS_dbEntities db = new IDMS_dbEntities();
try
{
dataGrid.ItemsSource = db.tblAIs.Where(a => a.ButtockNo.StartsWith(textBox.Text.Trim())).ToList();
}
catch
{
}
}
}
}