As you can see in returned DataView I do not get any rows while I will expect 1.
Please let me know if I can make it clearer.
Here is sample code -
DataSet m_ds = new DataSet("testdataset");
DataTable dt = new DataTable("testtable");
DataColumn dc = new DataColumn("id",System.Type.GetType("System.Int32"));
dt.Columns.Add(dc);
dc = new DataColumn("name",System.Type.GetType("System.String"));
dt.Columns.Add(dc);
m_ds.Tables.Add(dt);
for (int i=0; i<10; i++)
{
DataRow dr = dt.NewRow();
dr[0] = i;
dr[1] = i.ToString() + "_name_".PadRight(100,'z');
dt.Rows.Add(dr);
}
dt.AcceptChanges();
// Call BeginEdit() on 10th row as it would be databound when view will be crated in actual application
dt.Rows[9].BeginEdit();
// Change 10th row to Modified status
dt.Rows[9]["Name"] = "timbuktu";
// Add one row so that its status is Added
DataRow dr2 = dt.NewRow();
dr2[0] = 100;
dr2[1] = "";
dt.Rows.Add(dr2);
// Dump Contents of Table
foreach (DataRow drThis in dt.Rows)
System.Diagnostics.Debug.WriteLine("ID = " + drThis["id"] + ", name = " + drThis["name"]);
// Now get View with rowfilter name = 'timbuktu'
DataView dv = new DataView(dt,"name = 'timbuktu'","",DataViewRowState.CurrentRows);
System.Diagnostics.Debug.WriteLine("Result of Test Application follows ------->");
System.Diagnostics.Debug.WriteLine("DataView row count = " + dv.Count.ToString());
And here is program output -
ID = 0, name = 0_name_zzzz
ID = 1, name = 1_name_zzzz
ID = 2, name = 2_name_zzzz
ID = 3, name = 3_name_zzzz
ID = 4, name = 4_name_zzzz
ID = 5, name = 5_name_zzzz
ID = 6, name = 6_name_zzzz
ID = 7, name = 7_name_zzzz
ID = 8, name = 8_name_zzzz
ID = 9, name = timbuktu
ID = 100, name =
Result of Test Application follows ------->
DataView row count = 0
Cor Ligthert said:
Hi Bill,
That is as Jon wrote, I am currious as well for this one.
Cor