none
XML -> DataSet -> DataGrid (Load,Modify,Save)

    Question

  • Hello guys,

    first of all I'm new both to VS and .Net.

    I want to display a XML file in a dataGrid.

    XML file:

    <ROOT>

        <GENERAL>

            <NAME>APP1</NAME>

            <LANG>EN</LANG>

        </GENERAL>

        <RESOURCES>

            <ELEMENT CKEY="save" LENGTH="0" TYPE="BUTTON">Save</ELEMENT>

            <ELEMENT CKEY="cancel" LENGTH="0" TYPE="BUTTON">Cancel</ELEMENT>

        </RESOURCES>

    </ROOT>

     

    How to get the ELEMENT nodes into a dataGrid?

    The dataGrid I have includes the columns: key, value, length, elementType

    I have a dataSet with a table and same columns.

    How to load the right data into the dataSet and how to display it in dataGrid?

    I have a piece of code which should rather do it:

     

    XmlDataDocument xDoc = new XmlDataDocument();

    xDox.DataSet.ReadXml(filePath);

    dataGridView1.DataSource = xDoc.DataSet;

    dataGridView1.DataMember = "RESOURCES.RESOURCES_ELEMENT";

     

    I don't see the data in the dataGrid. I see only the right number of empty rows (2).

    How to associate the columns with the approriate attributes and values of the XML nodes?

     

    I want to select the elementType of each row in the dataGrid from a dropDownMenu.

    How to implement such a dropDownMenu-interated-dataGrid?

     

    The application shall have load, modify (e.g. add new row) and save functionality.

     

    Thx in advance and best regards,

    fuddy

     

    Friday, March 09, 2007 8:46 AM

Answers

  • Hi,

    I'm slowly getting to solve the problems myself:

    I named the columns in the dataSet-table with CKEY, LENGTH, TYPE, VALUE

    Now the XML data is loaded into the right columns out of the node's attributes.

    The VALUE column stays empty.

    What is the right name for the column which shall contain the node value?

    I figured out how to associate the dataGrid columns with the dataSet columns:

    dataGridView1 -> Columns -> Column -> DataPropertyName

    I also set the ColumnType of dataGrid TYPE column to "DataGridViewComboBoxColumn".

     

    Best regards,

    fuddy

     

     

     

     

     fuddy wrote:

    How to get the ELEMENT nodes into a dataGrid?

    How to load the right data into the dataSet and how to display it in dataGrid?

    How to associate the columns with the approriate attributes and values of the XML nodes?

    How to implement such a dropDownMenu-interated-dataGrid?

    Friday, March 09, 2007 10:00 AM
  • >>What is the right name for the column which shall contain the node value?

    -> ELEMENT_Text

     

    other questions gonna coming up soon...

    Friday, March 09, 2007 1:32 PM

All replies

  • Hi,

    I'm slowly getting to solve the problems myself:

    I named the columns in the dataSet-table with CKEY, LENGTH, TYPE, VALUE

    Now the XML data is loaded into the right columns out of the node's attributes.

    The VALUE column stays empty.

    What is the right name for the column which shall contain the node value?

    I figured out how to associate the dataGrid columns with the dataSet columns:

    dataGridView1 -> Columns -> Column -> DataPropertyName

    I also set the ColumnType of dataGrid TYPE column to "DataGridViewComboBoxColumn".

     

    Best regards,

    fuddy

     

     

     

     

     fuddy wrote:

    How to get the ELEMENT nodes into a dataGrid?

    How to load the right data into the dataSet and how to display it in dataGrid?

    How to associate the columns with the approriate attributes and values of the XML nodes?

    How to implement such a dropDownMenu-interated-dataGrid?

    Friday, March 09, 2007 10:00 AM
  • >>What is the right name for the column which shall contain the node value?

    -> ELEMENT_Text

     

    other questions gonna coming up soon...

    Friday, March 09, 2007 1:32 PM