Create Dataset and datatable Add the columns
public Form1()
{
InitializeComponent();
GINdata();
}
DataSet ds = new DataSet();
DataTable dt = new DataTable();
public DataTable GINdata()
{
dt.Columns.Add(new DataColumn("vname", typeof(System.String)));
dt.Columns.Add(new DataColumn("Rate", typeof(System.String)));
return dt;
}
Add One button
in btn Click if check box is placed in cells[2] then write this code
for (int i = dataGridView1.Rows.Count - 1; i >= 0; i--)
{
if ((bool)dataGridView1.Rows[i].Cells[2].FormattedValue)
{
DataRow dr = dt.NewRow();
dr["vname"] = dataGridView1.Rows[i].Cells["vname"].Value;
dr["Rate"] = dataGridView1.Rows[i].Cells["Rate"].Value;
dt.Rows.Add(dr);
}
--------------------------------
Add the datatable into dataset
ds.Tables.Add(dt);
string XML = ds.GetXml();
MessageBox.Show(XML);