Skip to main content

Posts

Showing posts from March 10, 2017

Export DataTable to HTML in C#

Introduction I would like to share a way by which we can export a DataTable to HTML format. This code can be used for reporting purposes where sometimes the client needs output data in HTML format. First we will bind the DataTable to a DataGridView. A. Binding DataGridView using DataTable Procedure Create a DataTable and define columns as in the following:  DataTable  table  =  new  DataTable();    table.Columns.Add("ID", typeof(int));    table.Columns.Add("NAME", typeof(string));    table.Columns.Add("CITY", typeof(string));   Add rows as in the following: table.Rows.Add(111, "Devesh", "Ghaziabad");   table.Rows.Add(222, "ROLI", "KANPUR");   table.Rows.Add(102, "ROLI", "MAINPURI");   table.Rows.Add(212, "DEVESH", "KANPUR");   Binding DataGridView as in the following: dataGridView1.DataSourc...

Adding CheckBox Column in DataGridView in C# Window Forms

Introduction  I would like to share three ways to add a checkbox to a DataGridView in a C# Windows Forms application. We will learn the following three ways to add a checkbox to a DataGridView: Binding a List to a DataGridView having a bool property Binding a datatable to a DataGridView having a bool column Adding a checkbox column (DataGridViewCheckBoxColumn) to the DataGridView. Procedure 1. Binding a List to a DataGridView having a bool property. Add the following class to the project: public   class  Emp   {       public   bool  isMarried {  get ;  set ; }       public   string  Name {  get ;  set ; }       public   string  city {  get ;  set ; }      }   We have added isMarried as a Boolean property.   Creating a List of Emp c...

Contact Form

Name

Email *

Message *