Click here to Skip to main content
16,004,778 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

C#
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
    };

    Gridview_Input.Rows.Add(row);


code that i tried but this didn't work. any help please

C#
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);
               }
Posted

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900