title: Exporting contents of a TextBox to a Text File Visual Studio C#
body: <p>I am trying to export the contents of a textbox to a txt file at the press of a button "Export". I am using web application forms in Visual Studio in C#.</p>
  
  <p>I have got the txt file creation part working at the press of a button. But I am unable to export the data from the textbox into the text file.</p>
  
  <p>The textbox's contents are referencing a DataGrid so how can I link the program in C# so that at the press of the button "Export" it transfers the contents fo the textbox into the text file?</p>
  
  <p>So the code below is what I have to create a text file. What would I need to add to this, to do the above?</p>
  
  <pre><code>    private void Export_Click(object sender, EventArgs e)
      {
           //DataRowView drv = ((DataRowView)ordersBindingSource.Current);
           //DataRow dr = drv.Row;        
  
          string path = @"G:\bin\Debug\Test.txt";
          if (!File.Exists(path))
          {
              // Create a file to write to. 
              using (StreamWriter sw = File.CreateText(path))
              {
                  sw.WriteLine("Hi," + System.Environment.NewLine);
                  sw.WriteLine("Order ID: ");
              }
          }
      }
  </code></pre>
  
  <p>Please Help!! I am working on a project and stuck at this level of exporting information.</p>