I Have 1 Datatable having 10 rows and ListBox having 8 ListItems contains 6 records from the DataTable and 2 new records.
I want to update the DataTable in such a way that 6 records should be as it is and remove remaining 4 records from DataTable and add 2 newly added entries from ListBox in DataTable.
What I tried is I looped ListBox record from DataTable and created list of matched records.
string impactedTC;
List<int> index = new List<int>();
// This retruns my dataset having 10 records
DataTable dttable = GetImpactedTestCaseDetailsToUpdateStatus().Tables[0];
for (int i = 0; i < ListBox1.Items.Count; i++)
{
int count = 0;
string dTestCase = ListBox1.Items[i].Text;
foreach (DataRow dtRow in dttable.Rows)
{
impactedTC = dtRow["TestCaseName"].ToString();
if (impactedTC == dTestCase)
{
index.Add(count);
}
count++;
}
}