title: Displaying XML Records using Next/Previous Buttons in C#
body: <p>I'm trying to cycle through my XML records using a Next/Previous button. I have written code to fetch the first vendor, but the code I used to get the second vendor and third vendor and so on isn't working. I have included the initial code to retrieve the data, the loop that I tried and the XML file I was given.</p>
  
  <pre><code>    List &lt;Vendor&gt; v = VendorDB.GetVendors();
  
                 Vendor vendor1 = v[0];
  
                 txtName.Text = vendor1.Name.ToString();
                 txtAddress.Text = vendor1.Address.ToString();
                 txtCity.Text = vendor1.City.ToString();
                 txtZip.Text = vendor1.Zip.ToString();
                 txtPhone.Text = vendor1.Phone.ToString();
                 txtSalesYTD.Text = vendor1.YTD.ToString();
                 txtSalesRep.Text = vendor1.Contact.ToString();
                 txtComments.Text = vendor1.Comment.ToString();
  
              private void btnNext_Click(object sender, EventArgs e) //try doing if statements for each vendor
          {
              List&lt;Vendor&gt; v = VendorDB.GetVendors();
              for (int i = 0; i &lt; v.Count; i++)
              {
  
                  Vendor vendor1 = v[i];
                  txtName.Text = vendor1.Name.ToString();
                  txtAddress.Text = vendor1.Address.ToString();
                  txtCity.Text = vendor1.City.ToString();
                  txtZip.Text = vendor1.Zip.ToString();
                  txtPhone.Text = vendor1.Phone.ToString();
                  txtSalesYTD.Text = vendor1.YTD.ToString();
                  txtSalesRep.Text = vendor1.Contact.ToString();
                  txtComments.Text = vendor1.Comment.ToString();
              }
          }
  
          &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Vendors&gt;
    &lt;Vendor&gt;
      &lt;Name&gt;Scarmado Produce Co.&lt;/Name&gt;
      &lt;Address&gt;244 Southwest Dr.&lt;/Address&gt;
      &lt;City&gt;Bryan&lt;/City&gt;
      &lt;State&gt;Texas&lt;/State&gt;
      &lt;ZIP&gt;77805&lt;/ZIP&gt;
      &lt;Phone&gt;9797784456&lt;/Phone&gt;
      &lt;YTD&gt;2500000&lt;/YTD&gt;
      &lt;Comment&gt;Great vendor&lt;/Comment&gt;
      &lt;Contact&gt;James Scarmado&lt;/Contact&gt;
      &lt;DefaultDiscount&gt;15&lt;/DefaultDiscount&gt;
    &lt;/Vendor&gt;
    &lt;Vendor&gt;
      &lt;Name&gt;Talbort Restaurant Supplies&lt;/Name&gt;
      &lt;Address&gt;2533 Broadway Ave.&lt;/Address&gt;
      &lt;City&gt;New Orleans&lt;/City&gt;
      &lt;State&gt;LA USA&lt;/State&gt;
      &lt;ZIP&gt;89554&lt;/ZIP&gt;
      &lt;Phone&gt;7664028762&lt;/Phone&gt;
      &lt;YTD&gt;1589000&lt;/YTD&gt;
      &lt;Comment&gt;&lt;/Comment&gt;
      &lt;Contact&gt;Joan Fishing&lt;/Contact&gt;
      &lt;DefaultDiscount&gt;20&lt;/DefaultDiscount&gt;
    &lt;/Vendor&gt;
    &lt;Vendor&gt;
      &lt;Name&gt;Famous Meats&lt;/Name&gt;
      &lt;Address&gt;222 Swey Ave.&lt;/Address&gt;
      &lt;City&gt;Bangkok&lt;/City&gt;
      &lt;State&gt;Thailand&lt;/State&gt;
      &lt;ZIP&gt;75110&lt;/ZIP&gt;
      &lt;Phone&gt;883778723&lt;/Phone&gt;
      &lt;YTD&gt;186000&lt;/YTD&gt;
      &lt;Comment&gt;Good vendor&lt;/Comment&gt;
      &lt;Contact&gt;Faye Smith&lt;/Contact&gt;
      &lt;DefaultDiscount&gt;15&lt;/DefaultDiscount&gt;
    &lt;/Vendor&gt;
    &lt;Vendor&gt;
      &lt;Name&gt;Duetsch Products&lt;/Name&gt;
      &lt;Address&gt;253 Hamburg Ave.&lt;/Address&gt;
      &lt;City&gt;Hamburg&lt;/City&gt;
      &lt;State&gt;Germany&lt;/State&gt;
      &lt;ZIP&gt;APO 76632&lt;/ZIP&gt;
      &lt;Phone&gt;109019834&lt;/Phone&gt;
      &lt;YTD&gt;258260&lt;/YTD&gt;
      &lt;Comment&gt;Difficult delivery system&lt;/Comment&gt;
      &lt;Contact&gt;Ian Friberg&lt;/Contact&gt;
      &lt;DefaultDiscount&gt;20&lt;/DefaultDiscount&gt;
    &lt;/Vendor&gt;
    &lt;Vendor&gt;
      &lt;Name&gt;Allegheny Drink Products&lt;/Name&gt;
      &lt;Address&gt;2862 Hamilton St.&lt;/Address&gt;
      &lt;City&gt;Dallas&lt;/City&gt;
      &lt;State&gt;Texas&lt;/State&gt;
      &lt;ZIP&gt;80256&lt;/ZIP&gt;
      &lt;Phone&gt;7149872957&lt;/Phone&gt;
      &lt;YTD&gt;875390&lt;/YTD&gt;
      &lt;Comment&gt;&lt;/Comment&gt;
      &lt;Contact&gt;Cheryl Montana&lt;/Contact&gt;
      &lt;DefaultDiscount&gt;15&lt;/DefaultDiscount&gt;
    &lt;/Vendor&gt;
    &lt;Vendor&gt;
      &lt;Name&gt;Best Cheeses Around&lt;/Name&gt;
      &lt;Address&gt;2732 Gouda Ct.&lt;/Address&gt;
      &lt;City&gt;Lincoln&lt;/City&gt;
      &lt;State&gt;Nebraska USA&lt;/State&gt;
      &lt;ZIP&gt;67499&lt;/ZIP&gt;
      &lt;Phone&gt;4028776509&lt;/Phone&gt;
      &lt;YTD&gt;679270&lt;/YTD&gt;
      &lt;Comment&gt;&lt;/Comment&gt;
      &lt;Contact&gt;Dave Pfister&lt;/Contact&gt;
      &lt;DefaultDiscount&gt;15&lt;/DefaultDiscount&gt;
    &lt;/Vendor&gt;
  &lt;/Vendors&gt;
  </code></pre>