title: How to Bind The Database value in Datagridview textbox?
body: <p>I am using Windows form and C# and MySQL.</p>
  
  <p>In that i add three unbound columns in Datagridview with the help of control tag witch is in Datagridview right top.</p>
  
  <p>column1 is DataGridViewCheckBoxColumn.
  column 2 and 3 is DataGridViewTextBoxColumn.</p>
  
  <p>After that i wrote code to fill the Datagrid view.</p>
  
  <pre><code>connection.Open();
                   DataTable dt = new DataTable();
                   // Create a new data adapter based on the specified query.
                   MySqlDataAdapter da = new MySqlDataAdapter("select admin_no,name from " + FormName + " where class_code='" + class_code + "' and division_code='" + division_code + "' and Delete_Status = 0", connection);
                   //SQl command builder is used to get data from database based on query
                   MySqlCommandBuilder cmd = new MySqlCommandBuilder(da);
                   //Fill data table
                   da.Fill(dt);
                   //assigning data table to Datagridview
                   dataGridView1.DataSource = dt;
                   //Resize the Datagridview column to fit the gridview columns with data in datagridview
                   dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
                   connection.Close();
  </code></pre>
  
  <p>In That I got </p>
  
  <p><img src="https://i.stack.imgur.com/bidcy.png" alt="enter image description here"></p>
  
  <p>Here u see the two columns of Textbox is empty. and other two is added. </p>
  
  <p>I don't want to remove the textbox. So I want to populate the data with in my textbox, not a auto generated one.,..</p>
  
  <p>Please help me, to solve this problem....</p>
  
  <p>Thanks, I got the value in template Textbox columns. But the Last two columns of auto generated columns are added. How to remove that.</p>
  
  <pre><code>connection.Open();
                   DataTable dt = new DataTable();                 
                   MySqlDataAdapter da = new MySqlDataAdapter("select admin_no,name from " + FormName + " where class_code='" + class_code + "' and division_code='" + division_code + "' and Delete_Status = 0", connection);                 
                   MySqlCommandBuilder cmd = new MySqlCommandBuilder(da);                 
                   da.Fill(dt);                 
                   dataGridView1.DataSource = dt;                                 
                   dataGridView1.Columns[1].DataPropertyName = "admin_no";
                   dataGridView1.Columns[2].DataPropertyName = "name";
                   connection.Close();
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/WzPhv.png" alt="enter image description here"></p>
  
  <p>Help Me again Please.</p>
  
  <p>Sorry i forgot "dataGridView1.AutoGenerateColumns = false;".</p>
  
  <p>Thanks I got my requirement. </p>