title: GridView Create Fields Dynamically
body: <p>I would like somebody to help me to solve the following issue.</p>
  
  <p>I have a gridview, where the fields are created dynamically from codebehind.</p>
  
  <p>I would like to create with the same way(dynamically) a templateField which, if it is possible, to hold in it two button controls, having also and commandName.</p>
  
  <p>To be more clear:</p>
  
  <p>Headers-->>  First Name, LastName, Print(Daily/Invoices)</p>
  
  <p>Results  -->> FooFName, FooLName, <strong>Daily | Invoice</strong></p>
  
  <p>The bold one text is what I am looking for.</p>
  
  <p>I am posting also the methods and the way I use them to create the fields.</p>
  
  <pre><code>CreateBoundField(BillingSummaryGV, "Book_Date", "Date", "{0:dd/MM/yyyy}");
  
  CreateButtonField(BillingSummaryGV, "Print", "Print(Daily)", ButtonType.Link,"");
  
  BillingSummaryGV.DataSource = billingSummaries;
  BillingSummaryGV.DataBind();
  
  
  
  protected void CreateBoundField(GridView gv, string dataField, string headerText, string arrFormatingString) {
              var bf = new BoundField {
                  DataField = dataField,
                  DataFormatString = arrFormatingString,
                  HeaderText = headerText
              };
              gv.Columns.Add(bf);
          }
  
  private void CreateButtonField(GridView gv, string text, string headerText, ButtonType buttonType, string commandName) {
              var bfPrint = new ButtonField() {
                  ButtonType = buttonType,
                  Text = text,
                  HeaderText = headerText,
                  Visible = true,
                  CommandName = commandName
              };
              gv.Columns.Add(bfPrint);
          }
  </code></pre>
  
  <p>I would appreciate any reply</p>
  
  <p>thanks</p>