How to implement data validation on the data retrieved through a XML file via DataSet.

Hello,

As the subject says, I want to find a way through which I can apply data validation on the columns that are generated from a XML file when I read it from a DataSet Object.

There is a column which should only accept numeric values between a specific range. I know how to do it when I create my own columns and set appropriate properties for the same. but In case of this way of using DataSet I can't find a solution.

Below is the code I used to populate the data in the grid:

string datapath = <PATH TO XML>;
DataSet dataSet = new DataSet();
dataSet.ReadXml(datapath);
sfDataGrid1.DataSource = dataSet.Tables[0];

Furthermore, Why using this method it is creating new columns even If I've already defined the columns during design time? It creates 3 columns with same header text and then insert values in further rows causing previous cells to left empty. Is there anyway I can only extract values from the DataSet and insert below an appropriate column. 



You can see very well in the Image what exactly is happening (new columns instead of existing ones). 

Thank you

1 Reply 1 reply marked as answer

VS Vijayarasan Sivanandham Syncfusion Team December 22, 2020 01:36 PM UTC

Hi Shankul Gupta,

Thank you for contacting Syncfusion support.

Based on provided information we suspect that your manually defined column in you SfDataGrid. But AutoGenerateColumns doenot disabled in you SfDataGrid. So, already created column again regenerate in SfDataGrid.

Your requirement can be achieved by set false value in AutoGenerateColumns property in SfDatGrid. Please refer the below code snippet, 
sfDataGrid.AutoGenerateColumns = false; 

For more information, please refer the below UG link,

UG Link: https://help.syncfusion.com/windowsforms/datagrid/columns#manually-defining-columns 
If we misunderstood your requirement, please provide more information regarding the requirement. This would help us to proceed further.

Regards,
Vijayarasan S 


Marked as answer
Loader.
Up arrow icon