2个回答
展开全部
给你找了个例子,是直接绑定到数据库里的table的
后台代码:
MKP.MyCommon.SQLHelper sh = new MKP.MyCommon.SQLHelper(null);
DataTable dt=sh.GetDataTable("select Fi_id,Fs_pCompanyName,Fs_phone,Fs_email from TpmCompany");
dataGrid1.ItemsSource = dt.DefaultView;
前台代码:
<pre class="csharp" name="code"><DataGrid AutoGenerateColumns="False"
Height="153" HorizontalAlignment="Left" Name="dataGrid1" VerticalAlignment="Top"
Width="449" SelectedCellsChanged="dataGrid1_SelectedCellsChanged">
<DataGrid.Columns >
<DataGridTextColumn Header="ID" Binding="{Binding Path=Fi_id}"/>
<DataGridTextColumn Header="公司名称" Binding="{Binding Path=Fs_pCompanyName}"/>
<DataGridTextColumn Binding="{Binding Path=Fs_phone}" Header="电话" />
<DataGridTextColumn Binding="{Binding Path=Fs_email}" Header="Email"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
后台代码:
MKP.MyCommon.SQLHelper sh = new MKP.MyCommon.SQLHelper(null);
DataTable dt=sh.GetDataTable("select Fi_id,Fs_pCompanyName,Fs_phone,Fs_email from TpmCompany");
dataGrid1.ItemsSource = dt.DefaultView;
前台代码:
<pre class="csharp" name="code"><DataGrid AutoGenerateColumns="False"
Height="153" HorizontalAlignment="Left" Name="dataGrid1" VerticalAlignment="Top"
Width="449" SelectedCellsChanged="dataGrid1_SelectedCellsChanged">
<DataGrid.Columns >
<DataGridTextColumn Header="ID" Binding="{Binding Path=Fi_id}"/>
<DataGridTextColumn Header="公司名称" Binding="{Binding Path=Fs_pCompanyName}"/>
<DataGridTextColumn Binding="{Binding Path=Fs_phone}" Header="电话" />
<DataGridTextColumn Binding="{Binding Path=Fs_email}" Header="Email"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
展开全部
给你找了个例子,是直接绑定到数据库里的table的
后台代码:
MKP.MyCommon.SQLHelper
sh
=
new
MKP.MyCommon.SQLHelper(null);
DataTable
dt=sh.GetDataTable("select
Fi_id,Fs_pCompanyName,Fs_phone,Fs_email
from
TpmCompany");
dataGrid1.ItemsSource
=
dt.DefaultView;
前台代码:
<pre
class="csharp"
name="code"><DataGrid
AutoGenerateColumns="False"
Height="153"
HorizontalAlignment="Left"
Name="dataGrid1"
VerticalAlignment="Top"
Width="449"
SelectedCellsChanged="dataGrid1_SelectedCellsChanged">
<DataGrid.Columns
>
<DataGridTextColumn
Header="ID"
Binding="{Binding
Path=Fi_id}"/>
<DataGridTextColumn
Header="公司名称"
Binding="{Binding
Path=Fs_pCompanyName}"/>
<DataGridTextColumn
Binding="{Binding
Path=Fs_phone}"
Header="电话"
/>
<DataGridTextColumn
Binding="{Binding
Path=Fs_email}"
Header="Email"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
后台代码:
MKP.MyCommon.SQLHelper
sh
=
new
MKP.MyCommon.SQLHelper(null);
DataTable
dt=sh.GetDataTable("select
Fi_id,Fs_pCompanyName,Fs_phone,Fs_email
from
TpmCompany");
dataGrid1.ItemsSource
=
dt.DefaultView;
前台代码:
<pre
class="csharp"
name="code"><DataGrid
AutoGenerateColumns="False"
Height="153"
HorizontalAlignment="Left"
Name="dataGrid1"
VerticalAlignment="Top"
Width="449"
SelectedCellsChanged="dataGrid1_SelectedCellsChanged">
<DataGrid.Columns
>
<DataGridTextColumn
Header="ID"
Binding="{Binding
Path=Fi_id}"/>
<DataGridTextColumn
Header="公司名称"
Binding="{Binding
Path=Fs_pCompanyName}"/>
<DataGridTextColumn
Binding="{Binding
Path=Fs_phone}"
Header="电话"
/>
<DataGridTextColumn
Binding="{Binding
Path=Fs_email}"
Header="Email"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询