Hi,
I want to build RadMenu from an xml file and a dataset (xsd).
So I load my xml file into dataset.
Xml file:
and:
And I have an error: This constraint cannot be enabled as not all values have corresponding parent values.
I think that ParentId column in xml (set to null) isn't null in c#, it's a normal string.
Is that any solutions to avoid this? At now I change ParentId (in xml) to 0 and set null in c# code (I think that it's not a good idea) :
ParentId column in code of xsd file:
Any ideas how to proper make it?
I want to build RadMenu from an xml file and a dataset (xsd).
So I load my xml file into dataset.
Xml file:
| <?xml version="1.0" encoding="utf-8"?> |
| <MenuConfig xmlns="http://tempuri.org/MenuConfig.xsd"> |
| <MenuDT> |
| <Id>1</Id> |
| <Text>House</Text> |
| <URL>URL1</URL> |
| <CnfgId>1</CnfgId> |
| <ParentId>null</ParentId> |
| </MenuDT> |
| <MenuDT> |
| <Id>2</Id> |
| <Text>Cars</Text> |
| <URL>URL2</URL> |
| <CnfgId>1</CnfgId> |
| <ParentId>1</ParentId> |
| </MenuDT> |
| </MenuConfig> |
| MenuConfig menu = new MenuConfig();//dataset
menu.ReadXml(MapPath("App_Code/MenuConfig.xml"), System.Data.XmlReadMode.IgnoreSchema); |
| RadMenu1.DataSource = menu.Tables["MenuDT"]; |
| //Establish hierarchy: |
| RadMenu1.DataFieldID = "Id"; |
| RadMenu1.DataFieldParentID = "ParentId"; |
| //Set Text, Value, and NavigateUrl: |
| RadMenu1.DataTextField = "Text"; |
| RadMenu1.DataValueField = "Id"; |
| RadMenu1.DataNavigateUrlField = "URL"; |
| RadMenu1.DataBind(); |
And I have an error: This constraint cannot be enabled as not all values have corresponding parent values.
I think that ParentId column in xml (set to null) isn't null in c#, it's a normal string.
Is that any solutions to avoid this? At now I change ParentId (in xml) to 0 and set null in c# code (I think that it's not a good idea) :
| for (int ii = 0; ii < menu.Tables["MenuDT"].Rows.Count; ii++) |
| { |
| if (Convert.ToInt32((menu.Tables["MenuDT"].Rows[ii]["ParentId"])) == 0) |
| { |
| menu.Tables["MenuDT"].Rows[ii]["ParentId"] = null; |
| menu.Tables["MenuDT"].AcceptChanges(); |
| } |
| } |
ParentId column in code of xsd file:
| <xs:element name="ParentId" msprop:Generator_UserColumnName="ParentId" msprop:nullValue="_null" msprop:Generator_ColumnVarNameInTable="columnParentId" msprop:Generator_ColumnPropNameInTable="ParentIdColumn" msprop:Generator_ColumnPropNameInRow="ParentId" type="xs:string" minOccurs="0" /> |