Hi
Can anyone please tell how to work on validating the record entered from new row control(xamgrid) against the above existing records.
For eg. To check if duplicate records are not getting entered by the user from teh new row control.
I will highly appreciate if you can send me a small sample.
Thanks in advance.
Rakesh Bisht
Hello Rakesh,
Thank you for your feedback. I am glad that you have managed to solve your issue. Would you please explain what do you mean by “i feel the red background tooltip is not coming inherently from xamgrid” ?
Looking forward to hearing from you.
The main validation for me is to validate an item of a single column only against all the columns data.
And so I am using IDataerrorInfo.
I have been able to do it now.
Only issue now with me is to style the tooltip of the invalid cell.
Can you help me with this as i feel the red background tooltip is not coming inherently from xamgrid and I have to work on it.
Thanks
Rakesh
I have been looking into your requirements and making the validation when this event occurs is the best approach because using IDataErrorInfo you make validation for the separate columns, not for the whole rows.
Another option is to check whether the new added item is not the same as already existed one in your data collection.
Hi Yanko,
Thankyou for replying.
I am using MVVM pattern and IDataErrorInfo for the same.
Can you please suggest a way using MVVM with a small sample.
I have been looking into your question and if you want to make some validation when adding new row in the XamGrid control, the best choice is on ‘RowAdding’ event. For example, if you want to restrict the adding of a new row which has the same data as an existing one you can do the following check in the event’s body :
private void xamGrid1_RowAdding(object sender, Infragistics.Controls.Grids.CancellableRowAddingEventArgs e)
{
foreach (Row item in this.xamGrid1.Rows)
if (e.Row.Cells[0].Value.ToString() == item.Cells[0].Value.ToString() && e.Row.Cells[1].Value.ToString() == item.Cells[1].Value.ToString())
e.Cancel = true;
}
Let me know, if you need any further assistance on this matter.