lundi 14 novembre 2016

Getting Row /multiple Row data in datagridview when checkbox is checked using c#

Hi I would like to ask a solution where i can get the whole row data or multiple rows from a datagridview if the checkbox is checked and save it to an xml file

here is my exisiting code

private void button1_Click(object sender, EventArgs e)
{
  DataTable dt = new DataTable();
  dt = ds.Tables["Tables"];
  DataView view = new DataView(dt);
  view.RowFilter = "MD_ID = " + MdNum;

  //add checkbox to datagrid data
  dataGridView2.Columns.Add(chk);
  chk.HeaderText = "Select";

  //populate datagridview with data
  dataGridView2.DataSource = view;
}

private void SaveBtn_Click(object sender, EventArgs e)
{

}

my table has 4 columns MD_Num, MD_ID, MD_AGE, MD_DATE. is it possible to select a row and insert each value of the column to an individual textbox and save it to an XML file with the ff format:

<MDS>
  <MD> 
      <Tables>
         <MD_Num>VALUE#</MD_Num>
         <MD_Num>VALUE#<MD_Num>
         <MD_AGE>VALUE#<MD_AGE>
         <MD_DATE>VALUE#<MD_DATE>
      <Tables>
  <MD>
</MDS>




Aucun commentaire:

Enregistrer un commentaire