samedi 25 juin 2016

Dynamic Binding of Dropdownlist value and Key Value pair value from XML, Using XMLparser and reflection

I have to parse and dynamically load and set the values from XML, using xml parser and reflection. The sample XMl is like below:

Test XML :

<?xml version="1.0" encoding="utf-8"?>
<form>
      <ID>123456</ID>
      <Name>Test</Name>
          <UIControls>
              <Control>
                  <FullyQualifiedClass>TextBox</FullyQualifiedClass>
                  <ID type="STRING">tb1</ID>
                  <Name type="STRING">ActivityCode</Name>
                  <Value/>
                  <DataType type="FieldDataTypes">STRING</DataType>
                  <HtmlAttributes collection="KeyValuePair[string, string]">b</HtmlAttributes>
              </Control>
               <Control>
                  <FullyQualifiedClass>DropdownListownList</FullyQualifiedClass>
                  <ID>ddl1</ID>
                  <Selection item="CollectionItem">
                      <CollectionItem>
                          <Value>one</Value>
                          <DisplayText>ONE</DisplayText>
                          <Selected>FALSE</Selected>
                      </CollectionItem>
                      <CollectionItem>
                          <Value>two</Value>
                          <DisplayText>TWO</DisplayText>
                          <Selected>true</Selected>
                      </CollectionItem>
                  </Selection>
              </Control>
          </UIControls>
</form>

Now, I need to iterate Dropdown list value and KeyValue pair value and set it into Form's Controlls dynamically using reflection. I can't set the value statically, since the value of the xml will be changed and I can use the same concept every where in the application. waiting for your valuable and earliest response. Thank you





Aucun commentaire:

Enregistrer un commentaire