IDE: Visual Studio 2003 .NET
OS: Xp Pro
SqlCommand cmd = sqlCon.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select OrderID from Orders";
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
adapter.SelectCommand = cmd;
DataSet dsResult = new DataSet();
adapter.Fill(dsResult, "Orders");
DataGridTableStyle tsl = new DataGridTableStyle();
DataGridColumnStyle testCol = new DataGridTextBoxColumn();
testCol.MappingName = "OrderID";
testCol.HeaderText = "Hello world";
testCol.Width = 150;
tsl.MappingName = "Orders";
tsl.GridColumnStyles.Add(testCol);
dataGrid1.TableStyles.Add(tsl);
dataGrid1.DataSource = dsResult;
dataGrid1.DataMember = "Orders";
This script fills a datagrid with the OrderID in Orders in database
NorthWind. My problem is that the first row displayed is OrderID=10249, but
there are one Order with id = 10248, and it isn't displayed until I click on
columnheader and sort the datagrid
Why??
Jeff