有三个查询条件查询不同的表,得到的数据显示在DataGrid中,为什么第一查询的时候DataGrid能显示所有查询出来的字段,为什么第二次查询的时候DataGrid中就不能显示所有的字段,但再次点击查询按钮的时候DataGrid又能显示所有的字段了?
请问这是为什么啊?
部分程序:
DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.ConnectionString, CommandType.Text, sql.ToString());
DataView dv = ds.Tables[0].DefaultView;
dv.AllowDelete = false;
dv.AllowEdit = false;
dv.AllowNew = false;

DataGridTableStyle tableStyle = new DataGridTableStyle();

//tableStyle.PreferredColumnWidth = 100;
tableStyle.MappingName = dv.Table.TableName;
// make the dataGrid use our new tablestyle and bind it to our table
dataGrid1.TableStyles.Clear(); dataGrid1.TableStyles.Add(tableStyle);