後給定的行索引我建立我與bindnig源數據網格:刪除行排序C#
SqlDataAdapter adapter = new SqlDataAdapter(Datenbank.cmd);
dataSet1.Tables.Clear();
adapter.Fill(dataSet1, "Table");
bs = new BindingSource();
bs.DataSource = dataSet1.Tables["Table"];
dataGridView1.DataSource = bs;
現在我有點電網
bs.Sort = "customer DESC";
現在我想刪除行0
dataSet1.Tables[0].Rows.RemoveAt(0);
然而,這是在位置0分選前的行會被刪除,而不是排它現在是在位置0
//編輯:是否有類似的test.Tables[0].Rows.InsertAt(newRow, 0);
?
與綁定源排序證明這一點,不排序的原始數據表它將它的一個副本分類。你最好使用數據鍵而不是行索引來刪除。 – 2012-02-17 20:59:30
@BrianDriscoll您能否詳細解釋如何使用數據鍵而不是行索引? – 2012-02-17 21:03:40