Monday, 20 April 2015

Check for duplicate and insert into a data table C#

//preparing the column and values to be searched inside the table.

    string find = "ReferredFieldId = '" + referredControlId + "' AND  FormulaFieldId = '" +          CalculateFormula.ID + "'";


  DataRow[] foundRows = FormulaFieldData.Select(find);

//checking any rows exists or not if not inserting

if (foundRows.Length.Equals(o))
                                    {

DataTable dt = FormulaFieldData;
                                        dt.Rows.Add(referredControlId, referredFieldName, referedFieldIds, CalculateFormula.ID, CalculateFormula.ToolTip);
                                        FormulaFieldData = dt;

}


No comments:

Post a Comment