How to add a unique constraint to a data table while ignoring blank rows.

  • Thread starter Thread starter Suresh700
  • Start date Start date
S

Suresh700

Guest
Hi,

I have a data table and I was able to add unique constraint to a data column using

dataTable.Constraints.Add(new UniqueConstraint(new DataColumn[] { dataTable.Columns["Name"] }));

The issue I am trying to solve is, when user decides to insert a bunch of rows first and then enter the data, with this constraint in place, data table throws an unique constraint error. Is there any way to make unique constraint ignore when its blank?

Continue reading...
 
Back
Top