DataSet dataSet = new DataSet(); dataSet.ReadXml(@"D:\HostAdded.xml"); DataRow row = dataSet.Tables[0].NewRow(); row.ItemArray = new object[] { txthostname.Text, ipAddr, txtusername.Text, txtpassword.Text }; dataSet.Tables[0].Rows.Add(row); dataGridView1.DataSource = dataSet; dataGridView1.DefaultCellStyle.ForeColor = Color.Red; dataGridView1.AutoGenerateColumns = false; txtLog.AppendText(Environment.NewLine + "\nRow added successfully"); createXML();
DataTable dt = new DataTable(); foreach (DataGridViewColumn col in dataGridView1.Columns) { dt.Columns.Add(col.HeaderText); } foreach (DataGridViewRow row in dataGridView1.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(@"D:/HostAdded.xml");
dataGridView1.DataSource = dataSet; dataGridView1.DataMember = "HostAdded";
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)