Hi
I'm importing data from excel to datagridview. Initially I'm bind the dataset to DGV. When I'm importing I'm checking whether the imported item is already existing in dataset if not available I'm adding the row to DS and then binding. I want to highlight the imported data from excel in DGV from those which is already existing at the time of import, how can I achieve this, can anyone help me,
Here is what Ive done so far
workbook = excelApp.Workbooks.Open(filename, 0, true, 5, "", "", true,
Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets.get_Item(1);
range = worksheet.UsedRange;
Array myValues = (Array)range.Cells.Value2;
int vertical = myValues.GetLength(0);
int horizontal = myValues.GetLength(1);
workbook.Close(true, null, null);
excelApp.Quit();
releaseObject(workbook);
releaseObject(worksheet);
releaseObject(excelApp);
for (int i = 1; i <= horizontal; i++)
{
DataRow objdr = dsobbtemp.Tables[0].NewRow();
objdr["objectRevisedName"] = myValues.GetValue(1, i).ToString();
srowFilter = "objectRevisedName = '" + objdr["objectRevisedName"].ToString() + "'";
if (dsobbtemp.Tables[0].Select(srowFilter).Length == 0)
{
dsobbtemp.Tables[0].Rows.Add(objdr);
}
}
objdt = dsobbtemp.Tables[0].GetChanges();
for (int i = 0; i < objdt.Rows.Count; i++)
{
SqlParameter[] sqlparam1 = {
new SqlParameter("@accountID",iaccountID), };
DBAccess objDBaccess = new DBAccess();
iResults = objDBaccess.ExecuteCommand("AddData", sqlparam1);
Thanks in Advance