Hi Ragni,
Thanks for contacting Syncfusion forums.
Query: "NullReferenceException: Object reference not
set to an instance of an object".
The reported issue occurred because the ID and ParentID
values are declared with string types, we suggest you to use int? type for ID
fields.
Query2: changed
data type of model properties "Id" & "ParentId"
from string to int, then other exception "ArgumentException: Argument
types do not match" comes.
To overcome this issue, we suggest you to set null value for
ParentID instead of “0”. Please refer the below code snippet.
<code>
[Model]
public class
TreeViewSampleModel
{
public int? Id { get; set; }
public int? ParentId { get; set; }
public string TemplateName { get;
set; }
}
[List]
new TreeViewSampleModel(){Id=1,
ParentId= null, TemplateName="Coil Tubing" };
new TreeViewSampleModel()
{ Id = 2, ParentId = null, TemplateName = "CH Jobs" };
new TreeViewSampleModel()
{ Id = 3, ParentId = null, TemplateName = "OH Services" };
new TreeViewSampleModel(){Id=4,
ParentId=3, TemplateName="RDT" };
new TreeViewSampleModel()
{Id=5, ParentId=3, TemplateName="Seismic"
};
</code>
We have also prepared a simple sample to recover the above
issues and the sample can be downloaded from the below link.
Please let us know if you have any other concerns.
Regards,
Meena
TreeView_ModelBinding_cdb488.zip