I have my dataset loaded which loads records already in an XML file (if there are any), and then I have the code set to add a row to the dataset based on field entries on my form. After the row is added, it is supposed to clear the text fields, and be ready to accept the next row entry.
However, once I go to enter that next row, all it does it replace the first row it added, it never adds additional rows to the dataset. Can anyone explain where I've gone wrong?
Here is the code:
//load data set info
DataSet ds = new DataSet("data");
bowlers.ReadXml(
Application.StartupPath + "\\file_" + GLB.filedate + ".xml");
dataGrid1.DataSource = bowlers;
dataGrid1.DataMember =
"bowlers";
DataRow dr = bowlers.Tables[0].NewRow();
dr[
"firstName"] = this.textBox1.Text;
dr[
"lastName"] = this.textBox2.Text;
if (this.checkBox1.Checked == true)
{
string jackpot = "Yes";
dr[
"jackpot"] = jackpot;
}
else
{
string jackpot = "No";
dr[
"jackpot"] = jackpot;
}
if (this.checkBox2.Checked == true)
{
string eliminator = "Yes";
dr[
"eliminator"] = eliminator;
}
else
{
string eliminator = "No";
dr[
"eliminator"] = eliminator;
}
dr[
"num_brackets"] = this.numbrackets.Text;
bowlers.Tables[0].Rows.Add(dr);