Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a datagridview which is populated at run-time and has a CheckBoxColumn as its first column.
When i am trying to save the contents of the datagridview with no rows selected, i.e. no checkbox selected, the value of all the checkboxes should be FALSE and that should be written to the file. Instead nothing is mentioned about the checkbox column, it is omitted
For example, The file should be saved as :
XML
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
  <Table1>
    <Select>False</Select>
    <Island>AppReplayIp.zip</Island>
    <PortConfig>abc</PortConfig>
    <Time_x0020_Out>200</Time_x0020_Out>
    <Host_x0020_Name>ixin-sovit</Host_x0020_Name>
  </Table1>
</NewDataSet>


But instead
XML
<Table1>
  <Island>AppReplayIp.zip</Island>
  <PortConfig>abc</PortConfig>
  <Time_x0020_Out>200</Time_x0020_Out>
  <Host_x0020_Name>ixin-sovit</Host_x0020_Name>
</Table1>

Here we see the "select" column is not written to the file

My code for writing to the file is
C#
private void createXML(string filename)
       {
           DataTable dt = new DataTable();
           foreach (DataGridViewColumn col in dgvIsland.Columns)
           {
               dt.Columns.Add(col.HeaderText);
           }
           foreach (DataGridViewRow row in dgvIsland.Rows)
           {
               DataRow dRow = dt.NewRow();
               foreach (DataGridViewCell cell in row.Cells)
               {
                   dRow[cell.ColumnIndex] = cell.Value;
               }
               dt.Rows.Add(dRow);
           }
           DataSet ds = new DataSet();
           ds.Tables.Add(dt);
           ds.WriteXml(filename);
       }


How can i resolve this issue?Should any events be associated with the cell_click or something?
Please help!!! :)
Posted
Comments
gggustafson 22-May-14 14:37pm    
Are you going to rate/reply my solution to your earlier question?

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