Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

xml to data table and back to xml

$
0
0

I am reading an xml file into a data table and populating a listview.

  public static DataTable  createDataTable(string strFileName)
        {

            DataSet set = new DataSet();
            set.ReadXml(strFileName);//--->> read the xml file
            return set.Tables[0];

        }

On the listview selectedindex changedI want to bind the selected row a textbox and save the change to the data table, I then write the data table back to xml file.I need help to do this middle part.

  private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.listView1.SelectedItems.Count == 0) { return; }

            string strnumber = this.listView1.SelectedItems[0].Text;

            string strSearch = "number ='" + strnumber + "'";
            DataRow[] dr = table.Select(strSearch);

            //----->>>>> we found it
            this.textBox1.Text = dr[0]["number"].ToString();


        }
Any help would be appreciated. Thanks in advance


Viewing all articles
Browse latest Browse all 31927

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>