0

表已创建,但行是空的,为什么?

MySqlConnection conn = new MySqlConnection("...");
conn.Open();
MySqlCommand cmd = new MySqlCommand("select id,id_user,status,id_delivery_method,delivery_method,id_payment_method,payment_method,payment_info,user_name,user_phone from `request`", conn);
DataTable dt = new DataTable();
dt.Load(cmd.ExecuteReader());
dataGrid1.ItemsSource = dt.DefaultView;
4

1 回答 1

0

尝试自己设置AutoGenerateColums = false和定义列:

在 XAML 中:

<DataGrid ... AutoGenerateColums="false">
    <DataGrid.Columns><!-- Your columns --></DataGrid.Columns>
</DataGrid>

在代码隐藏中:

yourDatagrid.AutoGenerateColumns = false;
于 2012-06-25T10:57:33.103 回答