Enos

Enos

  • NA
  • 140
  • 26.2k

How to edit from the datagridview and save new changes

Feb 9 2015 8:18 AM
Hi,

I have a resource file which i read the data and load it to the grid-view. now i want the user to be able to edit from the grid and click save button which will save it as a new file of resx? how do i do that? this is the code for reading the file.
oDataSet = new DataSet(); //now am reading the files from the path that is selected XmlReadMode omode = oDataSet.ReadXml(PathSelection);  for (int i = 0; i < oDataSet.Tables[2].Rows.Count; i++) {     string comment = oDataSet.Tables["data"].Rows[i][2].ToString();     string font = Between(comment, "[Font]","[/Font]");     string datestamp = Between(comment, "[DateStamp]", "[/DateStamp]");     string commentVal = Between(comment, "[Comment]", "[/Comment]");      string[] row = new string[]      {          oDataSet.Tables["data"].Rows[i][0].ToString(),         oDataSet.Tables["data"].Rows[i][1].ToString(),          font,          datestamp,          commentVal     };

code that i tried that didn't work for me
foreach (DataGridViewRow _gd in Gridview_Input.Rows)                {                    DataRow _row = oDataSet.Tables["data"].NewRow();                    _row[0] = oDataSet.Tables["data"].Rows[0][0].ToString();                    if (_gd.Cells[1].Value.ToString() != null)                        _row[1] = _gd.Cells[1].Value.ToString();                      if (_gd.Cells[2].Value.ToString() != null)                        _row[2] = _gd.Cells[2].Value.ToString();                      if (_gd.Cells[3].Value.ToString() != null)                        _row[3] = _gd.Cells[3].Value.ToString();                      if (_gd.Cells[4].Value.ToString() != null)                        _row[4] = _gd.Cells[4].Value.ToString();                      oDataSet.Tables["data"].Rows.Add(_row);                    Gridview_Input.Rows.Add(_row);                }

Answers (1)