You are trying to bind the datasource to a single class, but a datasource needs a collection of classes. If you want to bind a datasource to a single class you need to make a collection that only has that class in it
GridView1.DataSource = new List<mainobject>{a};